while asp.net core does not use web.config, IIS does and the maxAllowedContentLength controls this. The publish creates the web.config if the project does not have one.
Request length difference Azure app service deployed on Windows and Linux
Hi,
I have one application implemented using web api 6 which is deployed on windows flavor. which is causing issue while trying to upload even 100 mb file
"the page was not displayed because the request entity is too large."
How can increase the request length which supports upto 300 mb request size.
it is an web api 6 project and does not have any web.config file
The same application deployed on linux flavor works fine even for 300 mb request length.
Please suggest how to do it
2 answers
Sort by: Most helpful
-
-
ajkuma 27,946 Reputation points Microsoft Employee
2023-03-17T11:31:27.7833333+00:00 Based on your issue description, I understand the same config works fine on Linux, but not on Windows. Just confirming, if the same issue happens locally?
I have also added additional tags' to receive insights from the targetted SMEs.
If you haven't done this already, to increase the request length in your Web API 6 project, you can add the following code in the Startup.cs file:
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; namespace WebApi6 { public class Startup { public void ConfigureServices(IServiceCollection services) { services.Configure<FormOptions>(x => { x.ValueLengthLimit = int.MaxValue; x.MultipartBodyLengthLimit = int.MaxValue; x.MultipartHeadersLengthLimit = int.MaxValue; }); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseMvc(); } } }
The above code sets the maximum length for the request body, the multipart body, and the multipart headers to the maximum value that can be represented by an integer.
If you haven't done this already so, you may also set the maximum length to a specific value, such as 300 MB, by replacing
int.MaxValue
with the desired value in bytes.