Reputation: 203
Hi I want to ask how to configure blazor server side app to allow upload file greater than 28.6MB (Size bazed on this article: https://www.strathweb.com/2012/09/dealing-with-large-files-in-asp-net-web-api/).
I'm using BlazorInputFile and Tewr.Blazor.FileReader. Everything works fine while file size is smaller then about 23 MB. Bigger files hangs application. Both solutions stops when reading into memorystream occurs.
MemoryStream ms;
using (ms = new MemoryStream())
{
await file.Data.CopyToAsync(ms); <- STOPS HERE
ms.Dispose();
}
or
using (MemoryStream memoryStream = await file.CreateMemoryStreamAsync(100 * 1024 * 1024)) <-STOPS HERE
{
// Sync calls are ok once file is in memory
}
I tried multiple settings like:
services.AddSignalR(e =>
{
e.MaximumReceiveMessageSize = 100 * 1024 * 1024;
});
app.Use(async (context, next) =>
{
context.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = null;
await next.Invoke();
});
services.AddServerSideBlazor().AddHubOptions(o => o.MaximumReceiveMessageSize = 100 * 1024 * 1024);
but none of them works. Any Ideas?
Upvotes: 1
Views: 1849
Reputation: 1333
Not sure this is still the case but previously I've had to add a web.config file, even though they're not actually used in .net core and had to add the following entries:
<security>
<requestFiltering>
<!-- This will handle requests up to 50MB -->
<!--<requestLimits maxAllowedContentLength="52428800" />-->
<requestLimits maxAllowedContentLength="104857600" />
</requestFiltering>
</security>
Upvotes: 1