Asp.net mvc 3 'ModelType' not announced

I created an Asp.NET MVC 3 web application. However, when I try to deploy it, I get this error.

'ModelType' is not declared. It may not be available due to its level of protection.

on the second line of code where I declare my type of model. It works fine locally where MVC 3 is installed, but not on the server where it is missing. I have included the entire DLL that usually needs to be run without installation. Also this code works fine on another server where MVC 3 is not installed, so I'm not sure what the problem is.

here is the beginning of the code:

@Imports System.Data.SqlClient
@ModelType SqlDataReader

@Code
    Layout = Nothing
End Code

it does not work in the second line

+1
source share
2 answers

, MvcWebPageRazorHost .

, ~/Views/Web.config :

<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>
+7

, Web.config \Views\ . , "@ModelType . ..."

+1

All Articles