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>
There could be a few things going on here. Make sure you are following these guidelines
@inherits
directives in your views. unless you are using a custom view page base class they are unnecessary. For strongly-typed views you should use the @model
directive to specify the model type. For weekly-typed views you don't need anything.return View("ViewName", "MasterName")
since that might also cause conflicting templatign technologies to be used.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With