RadzenFileInput Closes server connection

Hello,

I am using the RadzenFileInput in my project to upload an image. When I try to upload the Image I get this screen:

When I check the browser's console I get this message "Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'."

This is the code that I am using:

  <RadzenFileInput @bind-Value="@(Image)" Style="width:150px;" TValue="string" Name="Image">
   </RadzenFileInput>

The variable 'Image' is a string. I Debugged the code to check if the variable gets any value but It is null.

I do not really know if the problem its because of the component or some configuration is needed to upload files. Would be nice to have some help.

Thank you :slight_smile:

Hi @Ruben_Agustin,

Not sure why you get this exception. You can try also our demo:
https://blazor.radzen.com/

The source code is here:

I'm have this exact same issue. The example on your site is the exact same as what you have in github. I thought it might have something to do with my file input being in a dialog, but I moved it out to another page and it still displayed the behavior. I wired up the change and error events, and neither one of them fire when this behavior occurs.

Hi @rodney.dixon!

In my case it happended to be a configuration problem in the Startup.cs file. The maximum size of the messages that could be received was too small. I just changed this in my Startup.cs file to set a bigger maximum size:

Hope that this solves your problem. Regards :wink:

That was it, thank you very much. How were you able to determine that was the issue? Is there another place to look for more descriptive errors when things like this happen?

Why use javascript for read image file?

My example:
// e = InputFileChangeEventArgs from Microsoft.AspNetCore.Components.Forms;

var imageFile = await e.File.RequestImageFileAsync("image/jpg", 460, 460);
var buffer = new byte[imageFile.Size];
await imageFile.OpenReadStream().ReadAsync(buffer);
string imageBase64 = $"data:{"image/jpg"};base64,{Convert.ToBase64String(buffer)}";