2011-03-01 66 views
7

我想第一次运行Razor Web项目的MVC3。该项目由S#arp Architecture生成,因此可能会丢失一些接线。MVC3应用程序忽略剃刀.cshtml扩展

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

的问题
[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] 

任何想法缺少什么?谢谢。

回答

8

在Global.asax.cs中

添加

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

Application_Start() 

的伎俩

+0

这是为什么需要?我在默认的MVC3项目中看不到这一行。谢谢。 – 2011-06-29 01:23:45

+0

查看引擎是可插入的。我只能猜测,mvc 3架构师认为我们不会缺乏默认的剃须刀!? – 2011-09-26 08:26:21