Custom Errors Page Problem
I have set the customErrors mode values to “On” in my web.config file of
my web application and I have specified a defaultRedirect URL for my error
page. I try to display the error details on my custom error page by calling
Server.GetlastError but the error context is not available on custom error
page (It returned nothing). It seems like the error context is lost when
the redirect to custom error page happens.
I try to overcome this problem by storing the error details using session
variables in the catch block and access them in the custom error page but
the session variable returned empty string.
The following are some of my codes:-
Catch ex As Exception
HttpContext.Current.Session("ExpMessage") = ex.Message
Throw New Exception("Class error. ", ex)
In custom error page Page_Load method,
lblErrorMessage.Text = HttpContext.Current.Session("ExpMessage")
I’m very interested to see if someone in this forum has a solution for this.
Thank in advance.