I'm trying to get working ASP.NET MVC 4 web application with ISS 6 and Windows Server 2003. I've followed the http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx and got MVC project loading. The problem is with Razor views that throw "
The view at '~/Views/Home/Index.cshtml' must derive from WebViewPage, or WebViewPage.
I've checked ".. must derive from WebViewPage, or WebViewPage<TModel>" on MonoDevelop & MVC3 (OS X) and my web.config is available in /views folder. Howerver I don't know if this is an IIS or ASP.NET issue but Views/Web.Config files is not considered when the web app is running.
Am I missing something with configuration?
You need an explicit namespace inclusion for
pageBaseType
This should be added to the web.config inside your Views folder.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.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.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.