MVC3 /剃刀:cshtml.Execute()“:发现改写没有合适的方法 [英] MVC3/Razor: cshtml.Execute()': no suitable method found to override

查看:310
本文介绍了MVC3 /剃刀:cshtml.Execute()“:发现改写没有合适的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换为使用RazorViewEngine的MVC2网站MVC3。我用这个工具升级我的项目和 Telerik的转换工具我的aspx意见转换成剃刀。该Telerik的工具把一个@inherits线在我的布局(从ViewMasterPage inherting)的顶部。当我试图运行使用的这些布局的一个网页,我得到了...... cshtml.Execute():发现改写没有合适的方法的错误。我删除了@inherits标签,并开始为我的主页工作。不过,我仍然得到这个错误使用相同的布局另一个页面。而现在,中移动有些事情要处理一个领域的问题后,我回到收到此错误为我所有的网页(那些我可以,反正)。

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 "....cshtml.Execute()': no suitable method found to override" error. 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).

我试图关闭Visual Studio中,删除临时文件等。

I have tried closing Visual Studio, deleting temporary files, etc.

推荐答案

想通了 - 下面的部分必须在的web.config 剃须刀 - 我有它在 web.configs 查看目录,但不是在 的web.config

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>

这篇关于MVC3 /剃刀:cshtml.Execute()“:发现改写没有合适的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆