Skip to main content
All docs
V23.2

Upload Control Troubleshooting

  • 10 minutes to read

This topic contains information about situations that may occur when operating ASPxUploadControl in standalone mode or embedded into ASPxHtmlEditor, ASPxFileManager, ASPxSpreadsheet, or ASPxRichEdit.

Important Notes

  • To post a selected file(s) to the server memory, the ASPxUploadControl must be placed into the <form> tag:
    <form runat="server" ... >
        <dx:ASPxUploadControl .../>
    </form>
    
  • ASPxUploadControl is rendered as the standard <input type="file"/> element. This element does not allow files to be persisted between requests and prohibits working with files and paths programmatically, because of the browsers security policy. Refer to the following article for more information: <input type=”file”>.
  • ASPxUploadControl requires ASPxUploadProgressHttpHandler to correctly process file upload in advanced upload mode and to support upload progress indication.

How To Access Other Control Values in File Upload Events

ASPxUploadControl uploads files to the Init event. When FileUploadComplete and FilesUploadComplete events fire, other controls on the page are not completely initialized and thus cannot be accessed.

Set the FileUploadMode property to OnPageLoad to upload files after page control hierarchy is built. In this case, you can access other controls on the page in the file upload events.

See the following topic for more information: Page Life Cycle During File Upload.

How To Redirect a Page When File Upload is Completed

It is not possible to execute a page redirect while a callback is uploaded. An attempt to call the Response.Redirect method in the FilesUploadComplete event handler causes the following exception:

The server encountered an internal unspecified error that prevented it from fulfilling the request.

Follow the steps below to perform a redirect after ASPxUploadControl uploads a file(s):

  1. Complete necessary operations in the server event handler and send required information to the client through the e.CallbackData property.

    protected void uplFile_FilesUploadComplete(object sender, FilesUploadCompleteEventArgs e) {
        //some actions  
        e.CallbackData = "ProjectDetail.aspx";  
    }  
    
  2. On the client side, subscribe to the FilesUploadComplete event.

    <dx:ASPxUploadControl ID="uplFile" runat="server" ...>  
        <ClientSideEvents FilesUploadComplete="redirect" />
    </dx:ASPxUploadControl>  
    
  3. In the event handler, redirect a user to another page.

    function redirect(s, e) {  
        if (!e.errorText) {  
            document.location.href = e.callbackData;  
        }  
    }  
    

How To Handle Internal Server Error

When, for instance, the total request length exceeds the maximum allowed length, the web server terminates this request prior to executing DevExpress code and an internal server error occurs. To catch and diagnose internal server exceptions, handle the Application_Error event in the Global.asax file:

void Application_Error(object sender, EventArgs e) {
    HttpServerUtility server = HttpContext.Current.Server;
    Exception exception = server.GetLastError();

    System.Diagnostics.Debug.WriteLine(exception.Message);

    if (exception.InnerException != null)
        System.Diagnostics.Debug.WriteLine(exception.InnerException.Message);
}

How To Specify Custom Error Messages

When you specify ValidationSettings, you can set error texts that are displayed when an uploaded file fails validation. The table below lists error text properties.

Error Text Property Error Description
GeneralErrorText An external error occurs during file uploading.
MaxFileCountErrorText The number of files selected for upload exceeds the maximum allowed value (MaxFileCount).
MaxFileSizeErrorText Uploaded file size exceeds the maximum allowed value (MaxFileSize).
MultiSelectionErrorText Editor validation fails in multi-file selection mode.
NotAllowedFileExtensionErrorText The selected file’s extension is not allowed (AllowedFileExtensions).

How To Customize Internal Server Error Text

When an internal server error occurs, the server throws the following general error message:

The server encountered an internal unspecified error that prevented it from fulfilling the request.

Use our localization technique to change this error text:

using DevExpress.Web.Localization;
using DevExpress.Utils.Localization.Internal;
using DevExpress.Utils.Localization;

protected void Page_Load(object sender, EventArgs e) {
    XtraLocalizer.QueryLocalizedString +=
    new EventHandler<XtraLocalizer.QueryLocalizedStringEventArgs>(XtraLocalizer_QueryLocalizedString);
}
static private void XtraLocalizer_QueryLocalizedString(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e) {
    if (e.StringIDType == typeof(ASPxperienceStringId)) {
        if ((ASPxperienceStringId)e.StringID == ASPxperienceStringId.UploadControl_UnspecifiedError)
            e.Value = "The total request length may exceed the maximum allowed length.";
    }
}

Why The Following Message Appears: “Please use a browser with HTML5 support…”?

This message appears when ASPxUploadControl operates in advanced upload mode and neither HTML5 nor Silverlight is available in a user browser.

Advanced upload mode implementation is based on HTML5 technology. If HTML5 support is not available in a user browser, this mode uses Microsoft Silverlight technology. If HTML5 is not supported and Silverlight is not installed or is disabled, the following message is displayed:

Please use a browser with HTML5 support; or install Microsoft Silverlight v3 or later to view this content and have an ability to upload files.

To solve this issue, set the UploadMode property to Auto to allow ASPxUploadControl to switch to standard upload mode if neither HTML5 nor Silverlight is available in the user’s browser.

Why The FileUploadComplete event does not fire, and the NotSupportedException or PlatformNotSupportedException is thrown when uploading a file(s)?

Additional information: known environments SharePoint 2010+, Shibboleth.

In standard upload mode, ASPxUploadControl uses HttpWorkerRequest objects to process progress requests. This object writes data to HttpRequest.ServerVariables collection that is not supported on the Windows Server 2008 R2 x64 and other Windows Server platforms.

To solve this issue, set the ShowProgressPanel property to false or use the advanced upload mode.

Why The Progress Panel Does Not Show Upload Progress?

The progress panel can work incorrectly in the following cases.

ASPxUploadProgressHttpHandler is not registered in Web.config

ASPxUploadControl requires ASPxUploadProgressHttpHandler to indicate upload progress. The handler is automatically registered in the configuration file if you use the DevExpress Template Gallery to create an application or if you add ASPxUploadControl to a form in the Design View.

If ASPxUploadProgressHttpHandler is not registered in the Web.config, define it manually as described in the following section: ASPxUploadProgressHttpHandler - Manual Registration.

Upload Control Operates in Standard Upload Mode And Application Trust Level Is Restricted

In standard upload mode, ASPxUploadControl uses HttpWorkerRequest objects to process progress requests. To work properly, these objects require Full .NET Trust Level permission. You can resolve this issue in the following ways:

  • In Medium trust level, set the UploadMode property to Advanced to use advanced upload mode.
  • In Medium trust level, set the ShowProgressPanel property to false to disable the progress panel.
  • Apply the Full trust level to your application. Note that in some cases, the progress panel does not show progress information under the Full trust level. This issue occurs when the Application Pool is set to Integrated mode. To resolve this issue, switch the application pool to Classic mode.

Exceptions Caused By An Unregistered ASPxUploadProgressHandlerPage.ashx

ASPxUploadControl requires ASPxUploadProgressHttpHandler to correctly process file upload in advanced upload mode and to support upload progress indication. If the handler is not registered the following exceptions can occur:

  • The ASPxUploadProgressHandlerPage.ashx handler is not registered in the web.config (section: system.webServer/handlers).
  • The file '/ASPxUploadProgressHandlerPage.ashx' does not exist.

To solve the issue, register ASPxUploadProgressHttpHandler manually as described in the following section: ASPxUploadProgressHttpHandler - Manual Registration.

(For MVC projects only). Additionally, make sure that there are no special rules for routing the {resource}.ashx URLs. Otherwise, add the following exception to your application:

protected void Application_Start() {
    ...
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes) {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.IgnoreRoute("{resource}.ashx/{*pathInfo}");
    ...
}

Exception: Access is denied

The Access is denied error can occur in the following cases.

The X-Frame-Options Header Is Set To Deny

The X-Frame-Options response header indicates whether a browser should be allowed to render a page in a <frame>, <iframe>, <embed>, or <object>. If the X-Frame-Options header is set to Deny, it affects the ASPxUploadControl since the control uses an <iframe> HTML element internally.

To solve the issue, remove the X-Frame-Options header or set its value to SAMEORIGIN at the application or IIS level.

  • Set the X-Frame-Options header at the application level in the Global.asax file:

    protected void Application_PreSendRequestHeaders(object sender, EventArgs e) {
        HttpContext.Current.Response.Headers.Remove("X-Frame-Options");
        HttpContext.Current.Response.AddHeader("X-Frame-Options", "SAMEORIGIN");
    }
    
  • Set the X-Frame-Options header at the IIS level in the Web.config file:

    <system.webServer>
        ...
        <httpProtocol>
            <customHeaders>
                <add name="X-Frame-Options" value="SAMEORIGIN" />
            </customHeaders>
        </httpProtocol>
        ...
    </system.webServer>
    

File Select Dialog is Invoked by a Custom Trigger

When you implement a custom Browse button or raise the click event of the <input type="file" \> HTML element, it causes the Access is denied error.

Use the DialogTriggerID property to specify the ID of a web control or HTML element that can invoke the Select File dialog. On the client side, the trigger elements can be specified by the SetDialogTriggerID(ids) method.

Exception: The Server Encountered an Internal Unspecified Error That Prevented It From Fulfilling The Request

You can catch this exception for the following reasons.

The Request Length Exceeds the Allowed Maximum Length

To solve this issue, switch to advanced upload mode or increase the allowed maximum length as follows.

Modify the maxRequestLength configuration setting (whose default value is 4096 in kilobytes) to increase the request length limit. In standard upload mode, maxRequestLength specifies the total size of all files selected and uploaded in a single request.

(For IIS7 only). In addition to maxRequestLength, customize the maxAllowedContentLength configuration setting (default value is 30000000, in bytes).

See the following topic for more information: Uploading Large Files.

<system.web>
    <httpRuntime maxRequestLength="30000" />
    ...
</system.web>
...

<!-- For IIS7 only -->
<system.webServer>
    ...
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="30000000" />
        </requestFiltering>
    </security>
</system.webServer>

A Web Server Returns Unexpected Response or Code

If a web server returns unexpected response or code, set the FileUploadMode property to OnPageLoad and upload a file(s) during the entire page postback instead of using the client Upload method.

Tracing Is Enabled

ASP.NET trace service adds debug information at the end of the server response. When a DevExpress control sends a callback and expects a JSON string in response, the added debug information cannot be parsed correctly by our scripts.

Disable the trace functionality in your application to resolve the issue.

Exception: The ValidationSettings.MaxFileSize property’s value exceeds the Web.Config’s maxRequestLength setting

In the Standard Upload Mode, if the MaxFileSize property value exceeds the value of the Web.config’s MaxRequestLength setting, the following error occurs:

The ValidationSettings.MaxFileSize property’s value exceeds the Web.Config’s maxRequestLength setting. For ASPxUploadControl’s built-in validation to work correctly, the ValidationSettings.MaxFileSize property should be less than the Web.config’s maxRequestLength setting.

To solve this issue, set the MaxFileSize value to less than the MaxRequestLength value or use the advanced upload mode.

Exception: The AdvancedModeSettings.PacketSize property’s value exceeds the Web.Config’s maxRequestLength setting

When the PacketSize property value exceeds the value of the Web.config’s MaxRequestLength setting, the following error occurs:

The AdvancedModeSettings.PacketSize property’s value exceeds the Web.Config’s maxRequestLength setting. For ASPxUploadControl to work correctly, the AdvancedModeSettings.PacketSize property should be less than the Web.config’s maxRequestLength setting.

To solve this issue, set the value of the PacketSize property to less than the value of the MaxRequestLength property.