Webforms 移植到 Razor MVC 错误
The view 'Art' or its master was not found. The following locations were searched
~/Views/Home/Art.aspx
~/Views/Home/Art.ascx
~/Views/Shared/Art.aspx
~/Views/Shared/Art.ascx
我使用 Razor View Engine
创建了视图。因此,该视图存在于 Home
文件夹下的 Views
文件夹中,名称为 Art.vbhtml
请告诉我如何告诉 Web 应用程序它需要使用 Razor View Engine
更新:
将 MVC 2.0 迁移到后使用 Razor 时出现问题MVC 3.0 RC 帮助了我,但现在它给出了这个错误......
Type 'RazorViewEngine' is not defined
尽管,视觉工作室中的智能感知正在显示它并突出显示为类名。
更新二:
Nathan Ratcliff 的回答有助于消除错误,但现在正在产生新的错误,其详细信息如下...
The view at '~/Views/Home/Art.vbhtml' must derive from WebViewPage, or WebViewPage<TModel>.
Nathan 你也能帮我解决这个问题吗?
答案摘要 对于那些后来到达这个阶段的人来说,所提供的答案足以澄清我的情况,但我想澄清一些有关答案的事情。
我必须执行以下步骤才能使 Razor 引擎在我的应用程序中运行(除了答案之外):
- 在项目的 Views 文件夹中添加了 web.config (在 web.config 中添加了下面答案中提供的代码部分) )。
- 在我的项目中添加了对 System.WebPages.dll 文件的引用。
The view 'Art' or its master was not found. The following locations were searched
~/Views/Home/Art.aspx
~/Views/Home/Art.ascx
~/Views/Shared/Art.aspx
~/Views/Shared/Art.ascx
I've created the view using the Razor View Engine
. So, the view exists in the Views
folder under the Home
folder with the name Art.vbhtml
Please tell me how to tell the web application that it needs to render the views using the Razor View Engine
UPDATE:
Problem using Razor after migrating MVC 2.0 to MVC 3.0 RC helped me, but now it is giving this error...
Type 'RazorViewEngine' is not defined
although, intellisense in the visual studio is showing it and highlighting as a class name as well.
UPDATE II:
Nathan Ratcliff's answer helped in removing the error, but now the new error is producing whose details are as under...
The view at '~/Views/Home/Art.vbhtml' must derive from WebViewPage, or WebViewPage<TModel>.
Nathan can you help me on this as well?
ANSWER SUMMARY
For those, who arrive later on this stage, the answer supplied is enough to clear my situation, but I would like to clarify a few things regarding the answer.
I had to perform the following steps to make the Razor Engine running in my application(apart from the answer):
- Added a web.config in the Views folder in the project (Added sections of code supplied in the answer below in the web.config).
- Added a reference for the System.WebPages.dll file in my project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您的 web.config 的编译部分中有此内容
并删除旧的。
另外,www.asp.net 关于从 2.0 升级的建议 -> 3.0
http://www.asp.net/learn/whitepapers/mvc3- release-notes#upgrading
编辑:
在您的视图文件夹中,有一个 web.config (不是项目根目录下的那个)。
它有剃刀配置部分吗?
Make sure you have this in the compilation section of your web.config
and remove the old one.
Also, www.asp.net's recommendations for upgrading from 2.0 -> 3.0
http://www.asp.net/learn/whitepapers/mvc3-release-notes#upgrading
Edit:
In your views folder, there is a web.config (not the one at the root of your project).
Does it have the razor config sections?