I use Application_Error to catch some legacy URLs and link 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 those that end in .aspx, are handled by aspnet_isapi.dll, so I can handle 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" />
In my development box (using Cassini), this works great in all cases: Both / badurl and /badurl.aspx cause Application_Error to fire.
In IIS7, however, /badurl.aspx works as expected, but / badurl simply leads to a generated server 404 page.
Any ideas what makes the difference, and how can I get IIS7 to replicate the behavior of the development server?
source share