Ticket T296086
Visible to All Users

CallbackError event handler is not invoked on a callback error

created 9 years ago

[DevExpress Support Team: CLONED FROM T295187: UploadControl - Uploading an empty file into Azure results in the "BadRequest RequestResult: InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format." error]
Hi,
I tried your solution to update the error message but the Application_Error would not get hit on a CallbackError.
When I try to upload an empty file with a breakpoint in the Application_Error method, the breakpoint will not get hit and the message will stay as it originally was.
I would upload a demo project but it won't let me upload a file more than 30MB

Answers approved by DevExpress Support

created 9 years ago

Hello,

In order to override callback error messages or handle callback exceptions in the required manner, set the ASPxWebControl.CallbackError event handler.
In this handler, determine the type of the exception and override the default exception handling process. For example:

  1. When you are trying to upload a file and there is an exception on the server side, the exception message is not informative enough or gives a user too much technical info.
C#
public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) { throw new Exception("CallbackException. Some error message you want to override!"); }

  1. When you set the ASPxWebControl.CallbackError event handler, you are able to override the default callback handling behavior. You can, for example, change the callback error message using ASPxWebControl.SetCallbackErrorMessage.
C#
protected void Application_Start() { ... DevExpress.Web.ASPxWebControl.CallbackError += Application_Error; } protected void Application_Error(object sender, EventArgs e) { Exception exception = System.Web.HttpContext.Current.Server.GetLastError(); if(exception.Message.StartsWith("CallbackException.")) DevExpress.Web.ASPxWebControl.SetCallbackErrorMessage("Upload failed. Please try again later."); }

I have created a sample project to illustrate this approach.

Best regards,
Pavlo

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.