I have a Razor Pages app with a file upload page. I want to allow up to 60 MB uploads on that page. I can get do this locally by adding a <requestLimits maxAllowedContentLength="62914560" />
tag to my local applicationhost.config
file in the .vs
directory, but that doesn't help the deploy.
Here's what I've tried
[RequestFormLimits(MultipartBodyLengthLimit = 60 * 1024 * 1024)]
and [RequestSizeLimit(60 * 1024 * 1024)]
to the PageModel
for the page in questionservices.Configure<FormOptions>(options => { options.MultipartBodyLengthLimit = 60 * 1024 * 1024; });
to my Startup.cs
app.UseWhen(context => context.Request.Path.StartsWithSegments("/mypagepath"), appBuilder => { appBuilder.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = null; });
Web.config
file to the root of the project with the <requestLimits>
tag. If I deploy that file the whole app stops working.Everything works locally but when I deploy to my Azure App Service, I get this error
The page was not displayed because the request entity is too large.
If you add web.config
file, you don't need to add anything in your code.
In .net core project, you also can use web.config
file.
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="62914560" /> <!--60MB-->
</requestFiltering>
</security>
</system.webServer>