Server.Transfer("error_404.aspx") in Application_Error returns a blank page
Posted
by qntmfred
on Stack Overflow
See other posts from Stack Overflow
or by qntmfred
Published on 2010-03-27T02:43:47Z
Indexed on
2010/03/27
2:53 UTC
Read the original article
Hit count: 419
I look for HttpExceptions in the Application_Error sub of my global.asx
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim ex As Exception = HttpContext.Current.Server.GetLastError()
If ex IsNot Nothing Then
If TypeOf (ex) Is HttpUnhandledException Then
If ex.InnerException Is Nothing Then
Server.Transfer("error.aspx", False)
End If
ex = ex.InnerException
End If
If TypeOf (ex) Is HttpException Then
Dim httpCode As Integer = CType(ex, HttpException).GetHttpCode()
If httpCode = 404 Then
Server.ClearError()
Server.Transfer("error_404.aspx", False)
End If
End If
End If
End Sub
I can step through this code and confirm it does hit the Server.Transfer("error_404.aspx"), as well as the Page_Load of error_404.aspx, but all it shows is a blank page.
© Stack Overflow or respective owner