This example is an MVC version of the How to use the ASPxWebControl.CallbackError event to handle application-level errors occurred inside ASPxWebControls during callback processing WebForms solution.
It illustrates how to catch and handle:
- Exceptions that occur inside DevExpress ASP.NET MVC extensions during a callback using the ASPxWebControl.CallbackError event;
- The remaining unhandled exceptions using the Application_Error event in the Global.asax file.
It also shows how to write required information to the same log/storage (for further diagnostics, etc).
Global.asax:
[C#]protectedvoidApplication_Start(){ASPxWebControl.CallbackError+=Application_Error;}
[VB.NET]ProtectedSub Application_Start()AddHandler ASPxWebControl.CallbackError, AddressOf Application_ErrorEndSub
[C#]protectedvoidApplication_Error(objectsender,EventArgse){Exceptionexception=HttpContext.Current.Server.GetLastError();if(exceptionisHttpUnhandledException)exception=exception.InnerException;AddToLog(exception.Message,exception.StackTrace);}
[VB.NET]ProtectedSub Application_Error(ByVal sender AsObject, ByVal e As EventArgs)Dim exception As Exception = HttpContext.Current.Server.GetLastError()If TypeOf exception Is HttpUnhandledException Then exception = exception.InnerExceptionEndIf AddToLog(exception.Message, exception.StackTrace)EndSub
The only difference is the format of the callbackErrorRedirectUrl configuration option. It should be set according to the routing configuration:
Web.config:
[XML]<configuration><devExpress> <errorscallbackErrorRedirectUrl="/Home/Error"/> </devExpress></configuration>
WebForms Version:
How to use the ASPxWebControl.CallbackError event to handle application-level errors occurred inside ASPxWebControls during callback processing
Question Comments
Added By: Mike McGrath at: 9/15/2015 9:11:57 AM
Our application is a web forms. What is required (DevExpress dlls) to support this
Added By: Sergi (DevExpress Support) at: 9/15/2015 9:20:42 AM Hello Mike,It seems that I provided you with the incorrect link in the T290000: ASPxUploadControl - The file upload cannot be completed due to an operation timeout - display this error to client ticket. I have updated the answer there.