aspnet-8879-common-concepts-callbacks-handle-callback-exceptions-handle-callback-exception-on-server.md
Use the static CallbackError event to handle a callback exception thrown by a DevExpress web control on the server side.
Delegate callback exception handling to the Application_Error event handler.
void Application_Start(object sender, EventArgs e) {
DevExpress.Web.ASPxWebControl.CallbackError += Application_Error;
}
Protected Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
DevExpress.Web.ASPxWebControl.CallbackError += AddressOf Application_Error
End Sub
In the Application_Error event handler, you can use the GetLastError() method to get the last exception’s details.
void Application_Error(object sender, EventArgs e) {
// Use HttpContext.Current to get a Web request processing helper
HttpServerUtility server = HttpContext.Current.Server;
Exception exception = server.GetLastError();
// Log an exception
AddToLog(exception.Message, exception.StackTrace);
}
Private Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Use HttpContext.Current to get a Web request processing helper
Dim server As HttpServerUtility = HttpContext.Current.Server
Dim exception As Exception = server.GetLastError()
' Log an exception
AddToLog(exception.Message, exception.StackTrace)
End Sub
View Example: How to handle application-level errors occurred during callbacks