Yeah, he's right. I just finished taking a class on ASP.Net, and this is something that we learned how to do. Basically, this is what you'd put inside your global.asax file:
CODE
Sub Application_Error(ByVal sender As Object, ByVal e As System.EventArgs)
Server.Transfer("appError.aspx")
End Sub
Which would then transfer your server data to
appError.aspx in the case of a problem. Inside appError.aspx, we had:
CODE
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim appError As System.Exception = Server.GetLastError()
Label1.Text = "Error Message: " & AppError.Message
Label1.Text &= "<p>Base Error Message: " & appError.GetBaseException.Message
If(TypeOf(appError) Is HttpException) Then
Dim checkException As HttpException = CType(appError,HttpException)
Select Case checkException.GetHttpCode
Case 403
Label2.Text = "You are not allowed to view that page."
Case 404
Label2.Text = "The page you requested cannot be found."
Case Else
Label2.Text = "The server has experienced an error."
End Select
Else
' The exception was not an HttpException
Label2.Text = "The following error occured:<br />" & appError.ToString()
End If
Label2.Text &= "<p>Please contact the server administrator.</p>"
Server.ClearError()
End Sub
appError.aspx also had two labels inside of it, named
Label1 and
Label2 so that we could output our error messages.
To call the custom error handler we built, we created a really quick sample page with a button and this code on it's clicked event:
CODE
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Throw New Exception("This is my error text")
End Sub
That worked for us; it's not exactly doing anything complex, but I think that all you'd need to change is what appError.aspx did with it's error information.
This post has been edited by girasquid: 19 Oct, 2007 - 09:55 AM