I am trying to convert an MVC2 site to MVC3 using RazorViewEngine.
I used this tool to upgrade my project and the Telerik converter tool to convert my .aspx views to Razor. The Telerik tool put an @inherits
line at the top of my layouts (inherting from ViewMasterPage).
When I tried to run a page that used one of these layouts, I got the error:
...cshtml.Execute(): no suitable method found to override
I removed the @inherits
tag and it started to work for my home page. However, I continued to get this error for another page using the same layout. And now, after moving some things around to deal with an Areas issue, I'm back to getting this error for all my pages (the ones I can get to, anyway).
I have tried closing Visual Studio, deleting temporary files, etc.
Figured it out - the following section needs to be in the web.config
for razor - I had it in the web.configs
in the Views
directories, but not in the root
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>