Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# MVC: Cannot Debug in IIS Express

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?

like image 383
Alvin Stefanus Avatar asked Dec 11 '17 04:12

Alvin Stefanus


Video Answer


2 Answers

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

like image 81
Saurabh Solanki Avatar answered Sep 19 '22 16:09

Saurabh Solanki


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

like image 41
emptyother Avatar answered Sep 18 '22 16:09

emptyother