How to Fix “HTTP Error 403.14 – Forbidden The Web server is configured to not list the contents of this directory”

This error occurs when you have MVC 2+ running hosted on IIS 7+, this is because ASP.NET 4 was not registered in IIS. In my case I was creating a MVC 3 project and hosting it on IIS 7.5.

To fix it, make sure you have MVC 2 or above and .Net Framework 4.0 installed, then run a command prompt as administrator and type the following line:

32bit (x86)

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

64bit (x64)

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

Configuring ASP.NET MVC on IIS 5 and IIS 6

I know there are other tutorials on the internet about this topic but I’m going to write here the way that worked for me.

Some tutorials I’ve seen tell you to change your Global.asax to add some routes. I didn’t have to change it at all. I only had to setup the IIS itself.

IIS 5

Configure your Virtual Directory as usual, then right click on it and select Properties. In the properties dialog, click on Configuration.  In this dialog, click on Add. Then use the settings below:

Configuring IIS 5

For Executable, use the following path:

c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll
or
c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll

depending on the version of .NET you are using on your application. You can copy the path from the other mappings that already exist.

Also make sure you uncheck the “Check that file exists” box.

Well, that is what it took for me to make it work on IIS 5.

IIS 6

For IIS 6 is not that different from what it needs on IIS 5. The process is the same until you get to the Configuration dialog. Now you add the same path showed above but the extension will change a bit. Take a look:

Configuring IIS 6

The option “Verify that file exists” must be unchecked.

After hitting OK, still in the Configuration dialog you have to add a Wildcard. Click on Insert and use the same DLL path you’ve been adding so far.

Configuring IIS 6

Once again, the option “Verify that file exists” must be unchecked – I know it’s annoying but that’s how it must be done.

See how the Configuration dialog must look like:

Configuring IIS 6

Note the extension and the wildcard added. Now, just hit OK and you’re done.

One thing I noticed is that if you name your Virtual Directory Anything.MVC it won’t work because of that “.mvc” extension you added.

Don’t worry. After doing that over and over again you get practice 😉

One good thing is that Microsoft is releasing a new Web Server called IIS Express which is as easy as the ASP.NET Development Server (that instance of Web Server that Visual Studio launches when you run a project) to configure but has almost all the features from the full version of IIS. On the new IIS Express you won’t need any extra configuration to have your ASP.NET MVC application up and running.

The new Microsoft WebMatrix – it’s like a small version of Visual Studio – already comes with the IIS Express. You can download WebMatrix here.