Upload component is not aware of upload errors

If I try to upload a file bigger than the allowed file size, the upload component calls the OnProgress function with 100% completion. The upload controller is not called as there is an error in the POST operation. The error I've got is this:

HTTP Error 404.13 - Not Found

The request filtering module is configured to deny a request that exceeds the request content length.

However, the blazor application does not get any error notification whatsoever, so it gets into an invalid state. I know that I can increment the file size limit in the application configuration files, but the point is that ther can be any error in the upload process (f.e. network error, server busy, etc) and the application would not get any feedback about it.

Please, add an onerror handler to the XMLHttpRequest in the javascript function upload to notify the upload component in case of any errors.

1 Like

Hi @manu,

Sure thing. We will take care of this in one of the following Radzen releases.

1 Like

I'd really like to have this added as well. I need the upload control to be able to handle the error coming back from the upload controller (I'm uploading a CSV file and then processing, and if it errors need to give error to user). Thanks!

Is there a solution to this topic? I'm trying to intercept when the user uploads a file with a wrong extension using the All files . selection in file type (I'm filtering only for pdf but all files is still there).
In the controller if the extension is not pdf I return a statuscode 400 with an error message and don't upload the file on the server.
But the component fires the upload complete and return 100% progress before firing the OnError event.
So it returns first the upload complete message and then an upload error message.

                        <RadzenUpload style="padding:2px 0px" Accept=".pdf" ChooseText="Cerca file" Url="@("upload/single?code="+prev.Code)" Visible="@(progress<100)" Error="@((args) => OnUploadError(args))" Complete="@((args) => OnComplete(args, "Upload"))" Progress="@((args) => OnProgress(args, "Upload"))" />

    public IActionResult Single(IFormFile file, string code)
                UploadFile(file, code);
                return StatusCode(200);
                return StatusCode(400, "Impossibile caricare files con estensione diversa da pdf");
        catch (Exception ex)
            return StatusCode(500, ex.Message);
1 Like

Just wondering if there's a solution for this yet. I have a similiar issue to Michele in this thread, where I check the extension of the file to see if it's allowed for upload. I'd like to give the user some feedback when they try to upload a file type that isn't allowed, right now the notification from AttachmentUploadButtonProgress(UploadProgressArgs args) always show.

RadzenUpload has an Error event now.

How do I go about to make use of it? I've tried to return a statuscode 500 when the wrong file type is uploaded but that doesn't really change anything.

I don't understand what you mean. Did you handle the Error event? What happens when you debug your code?

Sorry I was just tired and didn't understand I had to handle the event in Radzen, I was trying to figure out where in the code I could do this. The Error event works like a charm when I return 500, thanks.

This works:

            <RadzenUpload ChooseText="Upload Files" Multiple="true"
                          Style="margin-bottom: 20px;height: 45px"
                          Error="@((args) => UploadError(args))"
                          Progress="@((args) => OnProgress(args))" />
    private async void UploadError(UploadErrorEventArgs args)
        await DialogService.Alert(args.Message, "File Upload Error", new AlertOptions() { OkButtonText = "Ok" });