Put the following code in either your page, or in a base page class which
all your pages inherit from.
You would need to replace "ex.aspx" with the name of your error page, and
the Response.Redirect,
you would need to replace the argument with the path to your error page.
Where i have LastException = Server.GetLastError(), you could replace that
with any code you want.
In my base page class LastException is a protected property of type
Exception which simply wraps
a session variable. So i set this, then redirect to my exception page
(ex.aspx) which then takes care of
emailing or logging the exception, and displaying an appropriate message to
the user.
#Region " Page_Error "
Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Error
LastException = Server.GetLastError
If Me.PageNameFile <"ex.aspx" Then Response.Redirect("~/ex.aspx")
End Sub
#End Region
"Tom" <To*@discussions.microsoft.comwrote
On my web app (.net 05) I created a generic error handler class, now I
want
to be able to pass the error (from any page) to this class, then redirect
the
user to an error page with a user friendly message. I figured out how to
pass the error to the error class, but how can i redirect them to a user
friendly error page afterwards?