以为我的文件夹结构出错,但我认为我部署的mvc应用程序由于扩展而没有拿起网页。
当我输入根目录时,它会加载没有.cshtml的索引页。
当我尝试使用该页面中的一个链接时,网址加载时没有.cshtml,并说
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
如果我将它附加到.cshtml到最后我
Server Error in '/' Application.
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /Employee/_ViewEmpDetails.cshtml
我错过了一些设置吗?从来没有部署其中一个!
修改
尝试过运行
C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319> aspnet_regiis -i
但没有快乐。
EDIT2
我的路线配置,以防它与此有关:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Treeview", action = "Index", id = UrlParameter.Optional }
);
}
}
答案 0 :(得分:1)
MVC查找视图时的默认搜索路径如下:
~/Areas/AreaName/Views/ControllerName/ViewName.aspx
~/Areas/AreaName/Views/ControllerName/ViewName.ascx
~/Areas/AreaName/Views/Shared/ViewName.aspx
~/Areas/AreaName/Views/Shared/ViewName.ascx
~/Views/ControllerName/ViewName.aspx
~/Views/ControllerName/ViewName.ascx
~/Views/Shared/ViewName.aspx
~/Views/Shared/ViewName.ascx
~/Areas/AreaName/Views/ControllerName/ViewName.cshtml
~/Areas/AreaName/Views/ControllerName/ViewName.vbhtml
~/Areas/AreaName/Views/Shared/ViewName.cshtml
~/Areas/AreaName/Views/Shared/ViewName.vbhtml
~/Views/ControllerName/ViewName.cshtml
~/Views/ControllerName/ViewName.vbhtml
~/Views/Shared/ViewName.cshtml
~/Views/Shared/ViewName.vbhtml
如果这些不适合您,您可以customize them by extending the WebFormViewEngine and registering it in Global.asax。