Application Error Event

Like the Page_Error event, there is also an Application_Error event, which is declared in the global.asax file. For example, using similar code to above:

Sub Application_Error(Sender As Object, E As EventArgs) Dim err As String = "<h1>Application Error</h1>" & _

"Error in: " & Request.Url.ToString() & "<p/>" & _ "Stack Trace Below:<br/>" & _ Server.GetLastError().ToString()

Response.Write(err) Server.ClearError() End Sub

This event will be run if no Page_Error event traps the error. This event is one place where you could put application-wide error logging information.

0 0

Post a comment