FileUpload doesn't work
I add in attachment my sample code where I'm trying to use the SfFileUploader unsuccessfully
I'm working with Blazor server app and when I try to load a docx document, and then click on Upload I received the error " File failed to upload"
The code doesn't arrive to the "save" function in the controller
Can you tell me why it doesn't work ?
Thanks
Attachment: appsettings.Development_3b86bc13.zip
Hi Walter Martin,
After reviewing the shared sample code, we noticed that while the controller has been configured in your application, it hasn’t been registered in the Program.cs file. This is why the Save method in your controller isn’t being triggered when you attempt to upload a file.
To resolve this, please add the following lines to your Program.cs file so that the controller routes are properly registered and the upload functionality works as expected:
using Blazor1.Modelli; using BlazorApp1.Components; using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents();
builder.Services.AddSyncfusionBlazor();
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); }
app.UseHttpsRedirection();
app.UseAntiforgery();
app.MapStaticAssets(); app.MapRazorComponents<App>() .AddInteractiveServerRenderMode();
app.MapControllers();
app.Run();
|
Additionally, please ensure that your controller is modified as required to handle the file upload logic. Since you may have other configurations in place, kindly adjust the controller code accordingly so that the Save method processes the uploaded file as intended.
Including these lines will ensure that your controller is correctly mapped and the Save method is invoked during the file upload process.
many thanks
I forgot
builder.Services.AddControllers();
app.MapControllers();
Now it works
Hi Walter,
Thank you for the update. Please get back to us for assistance in the future.
Regards,
Shereen
- 3 Replies
- 3 Participants
-
WM Walter Martin
- Jan 2, 2026 03:07 PM UTC
- Jan 7, 2026 04:17 AM UTC