我有这个 ASP.NET MVC 3 应用程序,在使用 IIs Express 7.5 或 Cassini 进行本地开发时运行良好。
但是当我将应用程序部署到 IIs 7.5 上的真实网站(甚至在我的本地开发箱上)时,我感到害怕
The view 'Index' or its master was not found or no view engine supports the searched locations.
The following locations were searched:
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
我尝试了以下方法:
在
global.asax.cs
, 在 Application_Start()
中添加了这些行强制它仅使用 Razor View 引擎的方法:ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
但无济于事。
我发现此错误消息有点难以解决。有人可以给我一些关于寻找什么的指示吗?
最佳答案
好吧,我的错。
先拍后问的经典例子。 (或者反过来……)
首页/Index.cshtml
文件的构建操作设置为 None
因为某些原因。将其设置为 Content
解决了这个问题。
关于asp.net-mvc-3 - 部署到 "real"IIs 网站时默认 Razor View 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6413516/