I'm using Application_Error to catch some legacy URLs and URL shortcuts. In Global.vb I have this code:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim serverError = TryCast(Server.GetLastError(), HttpException)
If serverError IsNot Nothing Then
Dim errorCode As Integer = serverError.GetHttpCode()
If 404 = errorCode Then
' Do some custom processing here
End If
End If
End Sub
In web.config I have this, to ensure that all requests, not just ones ending in .aspx, are handled by aspnet_isapi.dll so I get to process them:
<add name="ASP.NET-ISAPI-2.0-Wildcard" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
On my development box (using Cassini), this works fine in all cases: Both /badurl and /badurl.aspx cause Application_Error to fire.
In IIS7, however, /badurl.aspx works as expected, but /badurl just results in a generic server-generated 404 page.
Any ideas what causes the difference, and how I can get IIS7 to replicate the development server's behavior?