Use the static ASPxWebControl.CallbackError event to handle callback exceptions thrown by DevExpress web controls server side. Delegate callback exception handling to the Application_Error
event handler.
void Application_Start(object sender, EventArgs e) {
// Assign Application_Error as a callback error handler
ASPxWebControl.CallbackError += new EventHandler(Application_Error);
}
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Assign Application_Error as a callback error handler
AddHandler ASPxWebControl.CallbackError, AddressOf Application_Error
End Sub
The Application_Error
event handler catches all unhandled ASP.NET errors while processing a request. You can use the GetLastError method to get and log the details of the last exception.
void Application_Error(object sender, EventArgs e) {
// Use HttpContext.Current to get a Web request processing helper
Exception exception = HttpContext.Current.Server.GetLastError();
if (exception is HttpUnhandledException)
exception = exception.InnerException;
// Log an exception
AddToLog(exception.Message, exception.StackTrace);
}
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Use HttpContext.Current to get a Web request processing helper
Dim exception As Exception = HttpContext.Current.Server.GetLastError()
If TypeOf exception Is HttpUnhandledException Then
exception = exception.InnerException
End If
' Log an exception
AddToLog(exception.Message, exception.StackTrace)
End Sub
When a callback exception occurs, you can redirect the application to another web resource. Use the callbackErrorRedirectUrl configuration option to specify the redirection location.
<configuration>
<devExpress>
<errors callbackErrorRedirectUrl="~/ErrorPage.aspx"/>
</devExpress>
</configuration>
Note
There are controls (for instance, ASPxUploadControl) that utilize the capabilities of the DevExpress.Web.ASPxUploadProgressHttpHandler handler to perform actions on a callback. System-level exceptions (request timeout, session timeout, etc.) that occur while executing the
ASPxUploadProgressHttpHandler
handler cannot be handled using theASPxWebControl.CallbackError
event. Use the defaultApplication_Error
event handler for this purpose.
- Global.asax (VB: Global.asax)
- Web.config (VB: Web.config)
(you will be redirected to DevExpress.com to submit your response)