Serve uploaded images as static assets.

This commit is contained in:
Atanas Korchev
2025-12-17 11:18:30 +02:00
parent 3710f4297b
commit 543dbc9e50
2 changed files with 8 additions and 1 deletions

View File

@@ -46,7 +46,7 @@ namespace RadzenBlazorDemos
file.CopyTo(stream);
// Return the URL of the file
var url = Url.Content($"~/{fileName}");
var url = Url.Content($"~/images/{fileName}");
return Ok(new { Url = url });
}

View File

@@ -115,7 +115,14 @@ if (!app.Environment.IsDevelopment())
Path.Combine(app.Environment.WebRootPath, "demos")),
RequestPath = "/demos"
});
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new PhysicalFileProvider(
Path.Combine(app.Environment.WebRootPath)),
RequestPath = "/images"
});
}
app.UseRouting();
app.UseAntiforgery();
app.MapGet("/llms.txt", () =>