crescendo
asked on
Server.GetLastError is Nothing on custom error page
I'm trying to write a custom error page, to display the error message within a page matching the "house style". I thought that I could use Server.GetLastError to get the exception that was thrown, but it has a value of "Nothing".
In my web.config I have:
<customErrors mode="On" defaultRedirect="error.asp x" />
And in the code-behind of error.aspx I have:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ex As Exception = Server.GetLastError ' <--- ex is Nothing at this point
lblError.Text = ex.Message
End Sub
This is making my custom error page pretty useless. What am I doing wrong?
In my web.config I have:
<customErrors mode="On" defaultRedirect="error.asp
And in the code-behind of error.aspx I have:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ex As Exception = Server.GetLastError ' <--- ex is Nothing at this point
lblError.Text = ex.Message
End Sub
This is making my custom error page pretty useless. What am I doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
see that event called when some error comes in your page ,, nor that page is loaded .. try to throw some error on page laod and see
Thank you for your patience
Open in new window