找到解决方案。我希望这有助于他人堆叠。以前的所有文章都很有用,帮助我更好地理解 IIS 工程。
如果站点没有正确的路由,它将显示不受欢迎的页面代码403.14。无法从没有获得必要权限的目录显示页面。当路由不正确时,它默认重定向到受服务器保护的目录。
我之前列出的这篇文章是最完整的。在 VS 2010/2012 安装过程之后部署第一个项目时出现此错误。所以,不要担心,它会发生。
- IIS 7.5 上的 ASP.NET MVC
ASP.NET MVC 3:未配置默认文档
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true"></modules> <!--THIS ONE -->
<!--<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
--><!-- any other modules you want to run in MVC e.g. FormsAuthentication, Roles etc. --><!--
</modules>-->
![当路由错误并且这部分在 *Web.config **<system.WebServer>*** 部分中启用时发生](https://i.stack.imgur.com/TFM4U.jpg)
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<!-- <modules runAllManagedModulesForAllRequests="true"></modules> -->
<modules> <!--THIS ONE -->
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
<!-- any other modules you want to run in MVC e.g. FormsAuthentication, Roles etc. -->
</modules>
</system.webServer>
![当路由错误并且这部分在 *Web.config **<system.WebServer>*** 部分中启用时发生](https://i.stack.imgur.com/CozBI.jpg)
我的贡献:
如果有人是 ReSharper 重构功能或任何其他重构工具的追随者,请注意不要随意使用它,因为它会出人意料地改变事情。不要误解我的话,它是一个迷人的 VS 插件,我在日常工作中使用它。但在我的情况下,它修改了 Global.asax.cs 文件的 RegisterRoutes (...) 中的路由参数,当然站点无法正确加载(甚至主页也不行)。
这是发生了什么{ id }:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL ORIGINAL VALUES
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
通过这个地狱{ referenceId }:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{referenceId}", // URL MODIFIED VALUES
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}