5
votes

I just changed my laptop. I am moving my old project done in MVC 4 and was done in Visual Studio 2012. My current Visual Studio in my new laptop is 2017 version.

There is a problem when I want to debug my MVC application. This error comes out after I run the debug:

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

Most likely causes: A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

I never set my application to be listed in directory browser. My application is an MVC application which will run global.asax and redirect to my home page.

How can I fix this?

4
Try changing the port on the project properties > Web > Project Url so you generate a new Virtual Directory. Are you using IIS Express or IIS?lloyd
I have tried to change it into localhost:9999/ but the same error still comes up. I use IIS Express to debug it.Alvin Stefanus

4 Answers

2
votes

enable directory browsing. keep this into your web config file then rename the add value="pagename.aspx"

 <system.webServer>
    <defaultDocument>
       <files>
          <add value="yourpage.aspx" />
       </files>
    </defaultDocument>
    <directoryBrowse enabled="false" />
</system.webServer>

or

 <system.webServer>
    <directoryBrowse enabled="true" />
</system.webServer>

You can also enable directory browsing from IIS

  • Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt: C:\Program Files\IIS Express
  • Type the following command, and then press Enter:

    appcmd set config /section:system.webServer/directoryBrowse /enabled:true

2
votes

Got the same error, but MVC5 on VS2017. Eventually found I got the error because i had marked Application_Start() in Global.asax as a static. I did that because i made the mistake of following this Code Analysis recommendation:

Member Application_Start does not access instance data and can be marked as static

1
votes

This is a potential duplicate of HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents

Different context since you are trying to debug in IIS express and you are not hosting the application in IIS, however the error is the same and the answers is worth checking out. Could set you on the right path.

Would have commented but don't have enough rep yet.

0
votes

Make sure you have defined your default application inside the hosts file in your new laptop.

This is a cause for many headache.

See it under:

C:/Windows/System32/Drivers/etc/hosts