MVC HTTP 错误 403.14 - Forbidden

HTTP 错误 403.14 - Forbidden

Web 服务器被配置为不列出此目录的内容。

最可能的原因:

  • 没有为请求的 URL 配置默认文档,并且没有在服务器上启用目录浏览。

可尝试的操作:

  • 如果不希望启用目录浏览,请确保配置了默认文档并且该文件存在。
  • 启用目录浏览。
    1. 转到 IIS Express 安装目录。
    2. 运行 appcmd set config /section:system.webServer/directoryBrowse /enabled:true 以在服务器级别启用目录浏览。
    3. 运行 appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true 以在网站级别启用目录浏览。
  • 确认网站或应用程序配置文件中的 configuration/system.webServer/directoryBrowse@enabled 属性已设置为 true。

 1.  网上查了资料下面解决方式不管用,后来自己想了一下是因为在RouterConfig 把默认路由注释掉了

  public static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapMvcAttributeRoutes();

            //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }

 

 

折腾了半天,提示里面的解决方法是:

  • 如果不希望启用目录浏览,请确保配置了默认文档并且该文件存在。
  • 使用 IIS 管理器启用目录浏览。
    1. 打开 IIS 管理器。
    2. 在“功能”视图中,双击“目录浏览”。
    3. 在“目录浏览”页上,在“操作”窗格中单击“启用”。
  • 确认站点或应用程序配置文件中的 configuration/system.webServer/directoryBrowse@enabled 特性被设置为 True。

按照该方法改后 ,发现网页运行界面进去的变成了目录结构,后来发现改配置文件web.config配置文件的配置节后,网站就可以正常使用了,记录下哦。

<system.webServer> 
<modules runAllManagedModulesForAllRequests="true" /> 
</system.webServer>

要设置<modules>节的值为true, 而目录浏览启用或禁用其实都没影响的。

posted @ 2015-08-29 15:24  Rocken.li  阅读(1186)  评论(0编辑  收藏  举报