MVC3应用程序忽略了Razor .cshtml扩展名

时间:2011-03-01 11:17:59

标签: asp.net asp.net-mvc-3 razor asp.net-mvc-routing

我第一次尝试使用Razor web项目运行MVC3。该项目由S#arp Architecture生成,因此可能缺少一些布线。

在Views文件夹下创建了带有Razor条目的事实上的web.config。这是〜/

的错误
[InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Index.aspx
~/Index.ascx
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx]

知道缺少什么吗?感谢。

1 个答案:

答案 0 :(得分:8)

添加

ViewEngines.Engines.Add(new RazorViewEngine());

Application_Start()

在Global.asax.cs

诀窍

相关问题