尝试将 MVC 应用程序部署为现有 ASP.NET 3.5 应用程序(非 MVC)的子应用程序时遇到问题。错误是:
The view 'index' or its master could not be found. The following locations were searched: ~/Views/employment/index.aspx ~/Views/employment/index.ascx ~/Views/Shared/index.aspx ~/Views/Shared/index.ascx
The application works fine when running inside of visual studio web developer express SP1 and also works when configured as the top level web site.
I'm developing under XP (IIS 6ish) so I've already configured the wildcard mappings etc. The MVC app is configured as a virtual folder directly underneath the root web site (http://localhost/ROHAS
where ROHAS is the virtual folder pointing to my MVC solution). I've also tried adding routes in the global.asax.cs to compensate for the sub application's virtual path:
routes.MapRoute("NetPortal", // Route name<br>
"localhost/rohas/{controller}/{action}/{id}");
还有
routes.MapRoute("NetPortal", // Route name<br>
"rohas/{controller}/{action}/{id}");
我什至尝试添加另一个虚拟文件夹,该文件夹仅指向我的 MVC 解决方案中的 Views 文件夹。
但是,我仍然收到上面详细说明的错误。
最佳答案
您必须在使用 MVC 项目的网站中创建一个虚拟目录,名称为“Views”,它指向 MVC 项目中的 Views 目录。确保在 IIS 管理器中创建仅具有“读取”访问权限的 VD,并确保您没有该 VD 的应用程序。
(VD -> 属性 -> 确保应用程序部分呈灰色)
关于c# - 部署到生产时找不到索引 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1378907/