asp.net mvc的3'ModelType'未声明 [英] asp.net mvc 3 'ModelType' is not declared
问题描述
我创建了一个Asp.NET MVC 3 Web应用程序。然而,当我尝试部署它,我得到这个错误。
I created an Asp.NET MVC 3 web application. However, when I try to deploy it I get this error.
ModelType'未声明。它可能无法访问由于其保护水平。
'ModelType' is not declared. It may be inaccessible due to its protection level.
在code,其中我宣布我的模型类型的第二行。它的伟大工程,其中本地MVC 3已安装,但在服务器上没有地方是没有的。我已经包括了所有dll的,它通常需要在不安装运行。另外这款code工作得很好,MVC 3没有安装,所以我不知道是什么问题,另一台服务器上。
on the second line of the code where I declare my model type. It works great locally where MVC 3 is installed but not on the server where it isn't. I've included all the dll's that it normally requires to run without the installation. Also this code works fine on another server where MVC 3 isn't installed so I'm not sure what the problem is.
这里是code的开头:
here is the beginning of the code:
@Imports System.Data.SqlClient
@ModelType SqlDataReader
@Code
Layout = Nothing
End Code
它未能在第二行
推荐答案
这会发生,如果的 MvcWebPageRazorHost没有注册。
请确保您有配置在〜/查看/ Web.config中
该服务器上:
Make sure that you have the configuration in your ~/Views/Web.config
on that server:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
这篇关于asp.net mvc的3'ModelType'未声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!