Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to use the ASPxWebControl.CallbackError event to handle application-level errors occurred inside ASPxWebControls during callback processing

$
0
0

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_Error EndSub

 

[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.InnerException EndIf 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


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>