Sometimes, on my Windows 7 laptop, my ASP.NET MVC applications would fail with an error like:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
Detailed Error Information
Module DirectoryListingModule
Notification ExecuteRequestHandler
Handler StaticFile Error
At the same time other MVC applications worked fine. So, I knew I had everything installed correctly. I tried the ideas in ASP.NET MVC on IIS 7.5 but none worked for me.
My guess was that MVC or ASP.NET was not configured correctly, so IIS did not interpret the URL correctly and map it as an MVC application that should use routing. The correct HttpModule was not being found, so IIS was treating the request as for a static page and redirecting to the folder, but since directory browse was not enabled, I was getting the error.
I finally stumbled around my file system and noticed two directories with config files:
- C:\inetpub\temp\appPools\DefaultAppPool\DefaultAppPool.config
- C:\inetpub\temp\appPools\ASP.NET V4.0 Integrated\ASP.NET V4.0 Integrated.config
These config files contained a bunch of incorrect application definitions. Some of these were for applications that did not show up in IIS Manager. Here is an example of two (one is incorrect, one is correct):
<system.applicationHost>
<sites>
<site name="Default Web Site" id="1" serverAutoStart="true">
<application path="/appsuite/billing/customer/log-in" applicationPool="ASP.NET V4.0 Integrated">
virtualDirectory path="/" physicalPath="C:\dev\appsuite\trunk\appsuite.Services\Billing\src\Billing" />
</application>
<application path="/appsuite/billing" applicationPool="ASP.NET V4.0 Integrated">
<virtualDirectory path="/" physicalPath="C:\dev\appsuite\trunk\appsuite.Services\Billing\src\Billing" />
</application>
My problem was when I attempted to request a URL that matched one of these apps with a bad path, like http://localhost/appsuite/billing/customer/log-in, I would get the 403 error.
I deleted everything in C:\inetpub\temp (I figured, hey it's a temp folder) and after hitting my url, the config files came back. I then manually deleted from the config file the applciation that matched my url and the app started working.
Where do the settings for these config files come from, where is the data coming from after I deleted them?
How can I clean up the old junk that is in them that isn't used any more?
I suspect I created this mess in Visual Studio. Sometimes when setting the Web properties of a project, I would accidentally set the Project URL to my launch URL, when I really meant to set the Start URL to this value. My guess is this set up a new web app with the url that matched my start page.