将MVC 2.0迁移到MVC 3.0 RC后使用Razor时出现问题
我将MVC 2.0站点迁移到MVC 3.0,使用的是: 使用ASPX作为查看引擎现在效果很好 但我试图创建一个Razor视图,结果出现了错误:将MVC 2.0迁移到MVC 3.0 RC后使用Razor时出现问题,razor,asp.net-mvc-3,Razor,Asp.net Mvc 3,我将MVC 2.0站点迁移到MVC 3.0,使用的是: 使用ASPX作为查看引擎现在效果很好 但我试图创建一个Razor视图,结果出现了错误: The view 'TestView' or its master was not found. The following locations were searched: ~/TestView.aspx ~/TestView.ascx ~/Views/Color/TestView.aspx ~/Views/Color
The view 'TestView' or its master was not found. The following locations were searched:
~/TestView.aspx
~/TestView.ascx
~/Views/Color/TestView.aspx
~/Views/Color/TestView.ascx
~/Views/Shared/TestView.aspx
~/Views/Shared/TestView.ascx
我怎样才能在上面启用razor
我正在使用Visual Studio 2010。。。
创建一个全新的MVC3Web应用程序可以让Razor变得更加出色
谢谢请查看
在解决方案资源管理器中,删除对System.Web.Mvc(指向版本2 DLL)的引用。然后添加对System.Web.Mvc(v3.0.0.0)的引用。同时添加对System.WebPages.dll和System.Web.Helpers.dll的引用。尝试添加
ViewEngines.Engines.add(新RazorViewEngine())
到global.asax文件中尝试添加ViewEngines.Engines.Add(新RazorViewEngine())代码>到你的global.asax文件就是这样!工作很好。。。把答案贴出来,这样我就可以接受了!谢谢