I had the same issue with IIS 7.5 in integrated mode.
In the end, I refused to handle the error in the web.config method and instead moved the error detection and handling to Application_EndRequest:
Add the following to your global.asax file:
If you do not have global.asax (MVC), you can add a page error instead.
Protected Sub Application_EndRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim context As HttpContext = HttpContext.Current.ApplicationInstance.Context If Not IsNothing(context) Then If context.Response.StatusCode = 404 And context.Response.SubStatusCode = 13 Then context.Response.ClearHeaders() context.Server.Transfer("~/errors/404.13.aspx", False) End If End If End Sub
George filippakos
source share