Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
693 views
in Technique[技术] by (71.8m points)

c# - HTTP Error 403.14 - Forbidden - MVC 4 with IIS Express

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

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.

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.

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.

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

But none of them worked.

Edit:

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 }
        );
    }

I am using T4MVC template.

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?

Thanks a lot in advance for your help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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?"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...