HTTP 错误 403.14 - Forbidden - MVC 4 with IIS Express [英] HTTP Error 403.14 - Forbidden - MVC 4 with IIS Express

查看:32
本文介绍了HTTP 错误 403.14 - Forbidden - MVC 4 with IIS Express的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个已经被问过/回答过很多次的问题.不是.

This seems like a question that has already been asked/answered many times. Its not.

开发环境:VS 2012 和 MVC 4.我使用内置的 IIS Express 来运行应用程序.

Development Environment: VS 2012 and MVC 4. I am using the built in IIS Express to run the app.

这个错误直到昨天才发生.它突然开始发生,我被卡住了.奇怪的是它只出现在一个场景中.

This error was not occurring until yesterday. It suddenly began to occur and I am stuck. Its strange that It occurs only in ONE scenario.

当我尝试访问 http://localhost:49962/managescholars/ 时,它显示了错误

When I try to access http://localhost:49962/managescholars/, it shows me the error

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

但是使用 http://localhost:49962/managescholars/Index 工作正常.同一控制器的其他动作方法也可以正常工作.例如 http://localhost:49962/managescholars/create.所有其他控制器也能正常工作.

But using http://localhost:49962/managescholars/Index works fine. Other action methods of same controller also work fine. such as http://localhost:49962/managescholars/create. All other controllers work fine as well.

我尝试将以下内容添加到 web.config.

I have tried adding the following to web.config.

<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules runAllManagedModulesForAllRequests="true" />
  <handlers/>
</system.webServer>

我也试过以管理员身份运行以下命令

I also have tried running the following command as administrator

%windir%Microsoft.NETFramework64v4.0.30319aspnet_regiis.exe -ir

但他们都没有工作.

我修改了路线.它们如下所示.

I have modified my routes. They look as follows.

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "ManageScholarLectures",
            url: "Manage/Lectures/{userFriendlyName}",
            defaults: new { controller = MVC.ManageLectures.Name , 
                            action = MVC.ManageLectures.ActionNames.Index, 
                            userFriendlyName = UrlParameter.Optional }
        );

        routes.MapRoute(
            name: "ManageScholarEdit",
            url: "Manage/Scholars/{userFriendlyName}",
            defaults: new { controller = MVC.ManageScholars.Name, 
                            action = MVC.ManageScholars.ActionNames.Edit }
        );

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

我正在使用 T4MVC 模板.

即使我将默认路由保留在底部并删除前两条路由,它仍然不起作用.我做错了什么?

It still does not work even if I leave the default route at the bottom and remove the first two routes. What have I done wrong?

非常感谢您的帮助.

推荐答案

你的路线看起来不错.这应该不会造成任何问题.该错误仅发生在 http://localhost:49962/managescholars/ 上,这意味着可能存在其他一些具有相同名称的资源.您能否确保您的代码在执行过程中不会错误地创建文件夹 ma​​nagescholars?"

Your routes seems fine. This should not cause any problem. The error is occuring only on http://localhost:49962/managescholars/ which means that there might be some other resource with same name. Can you make sure your code does not mistakenly creates a folder managescholars during execution?"

这篇关于HTTP 错误 403.14 - Forbidden - MVC 4 with IIS Express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆