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 illustrates how to catch and handle:
- Exceptions that occur inside DevExpress ASP.NET controls 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#]
voidApplication_Start(objectsender,EventArgse){// Assign Application_Error as a callback error handlerASPxWebControl.CallbackError+=newEventHandler(Application_Error);}

 

[VB.NET]
Sub Application_Start(ByVal sender AsObject, ByVal e As EventArgs) ' Assign Application_Error as a callback error handlerAddHandler ASPxWebControl.CallbackError, AddressOf Application_Error EndSub

 

[C#]
voidApplication_Error(objectsender,EventArgse){// Use HttpContext.Current to get a Web request processing helperExceptionexception=HttpContext.Current.Server.GetLastError();if(exceptionisHttpUnhandledException)exception=exception.InnerException;// Log an exceptionAddToLog(exception.Message,exception.StackTrace);}

 

[VB.NET]
Sub Application_Error(ByVal sender AsObject, ByVal e As EventArgs) ' Use HttpContext.Current to get a Web request processing helperDim exception As Exception = HttpContext.Current.Server.GetLastError() If TypeOf exception Is HttpUnhandledException Then exception = exception.InnerException EndIf' Log an exception AddToLog(exception.Message, exception.StackTrace) EndSub


By default, an unhandled exception occurs while a callback is displayed using the "alert" message.
In order to execute redirect to a custom error page, specify the callbackErrorRedirectUrl configuration option:

Web.config:

[XML]
<configuration><devExpress><errorscallbackErrorRedirectUrl="~/ErrorPage.aspx"/></devExpress></configuration>



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

Question Comments

Added By: okan sarıca at: 7/13/2012 2:21:38 AM    

i handle the exception in global asax but how can i send message to callbackcontrol for example ? if i throw a new exception in global asax e.message in callbackError function is 'some error occured'


Viewing all articles
Browse latest Browse all 7205

Trending Articles



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