Parse UploadCompleteEventArgs

After uploading multiple files I send back the number of successfully and failed files:
return StatusCode(200, new {_uploadService.FilesSuccess, _uploadService.FilesError });

On UploadComplete I want to parse this result to get back the number of success and failed files to provide a meaningful message to my user:

How to do this? I tried to JsonSerializer.Deserialize() args.JsonResponse and args.RawResponse, but couldn't solve this.

I suggest you check with the debugger what the event arguments are. Also you can check the server response is via the browser web tools.

Thanks for your quick reply.
The args are:


I can see the values I need, but I'm not sure how to extract them.

I recommend looking online how to use the System.Text.Json.JsonDocument class.

I'm gratefull for your patience.
Not only am I learning Radzen but also Blazor and .NET Core.
Making it hard for me to understand where to ask what.

I managed to get what I needed.

For future reference.
I created a struct to hold the results:

    public struct UploadResults
    {
        public int filesSuccess { get; set; }
        public int filesError { get; set; }
    }

Notice the first character is lower-case!

Next I used this struct to return in my controller:

return StatusCode(200, 
   new UploadResults {filesSuccess = _uploadService.FilesSuccess, 
                      filesError = _uploadService.FilesError });

And in my view I deserialize it:

var counts = JsonSerializer.Deserialize<MDGR.Web.Api.UploadResults>(args.RawResponse);
2 Likes