I recently upgraded from IIS 5 to IIS 7.5 (Server 2008 R2) and I am having trouble getting the same custom error behavior.
Everything works correctly if a physical directory does not exist:- mysite.com/i_dont_exist/: Correctly displays my custom error page.
- mysite.com/i_dont_exist/index.aspx: Correctly displays my custom error page.
- mysite.com/i_dont_exist/default.aspx: Correctly displays my custom error page.
- mysite.com/i_dont_exist/index.htm: Correctly displays my custom error page.
- mysite.com/i_dont_exist/anything_else/: Correctly displays my custom error page.
In IIS 5, unless I actually put an index or default file in a directory, IIS would always display my custom error page. However, in IIS 7.5 if I create an empty directory, here are my results:
- mysite.com/empty_directory/: Completely Blank Page (200 OK Status)
- mysite.com/empty_directory/index.aspx: Correctly displays my custom error page.
- mysite.com/empty_directory/default.aspx: Correctly displays my custom error page.
- mysite.com/empty_directory/index.htm: Correctly displays my custom error page.
- mysite.com/empty_directory/anything_else/: Correctly displays my custom error page.
My entire web.config looks like this:
---------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<trust level="Full" />
</system.web>
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="403" subStatusCode="14" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/" responseMode="ExecuteURL" />
<error statusCode="403" subStatusCode="14" prefixLanguageFilePath="" path="/" responseMode="ExecuteURL" />
</httpErrors>
<staticContent>
<mimeMap fileExtension=".otf" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
---------------------------------------------------
As you can see, I am using the web site root as my custom error page, but it works the same way if I use something like path="/404.aspx".
Failed Request Tracing gives me the following on a request to an empty directory:
---------------------------------------------------
273. -NOTIFY_MODULE_START
ModuleName CustomErrorModule
Notification 536870912
fIsPostNotification false
Notification SEND_RESPONSE
274. -GENERAL_NOT_SEND_CUSTOM_ERROR
Reason 1
Reason SETSTATUS_SUCCESS
---------------------------------------------------
I have been searching for days on this so any help/hints/suggestions would be greatly appreciated.
fodder.