Request length difference Azure app service deployed on Windows and Linux

Abdul Qadir 0 Reputation points
2023-03-13T21:41:15.13+00:00

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

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,133 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
292 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,810 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 54,626 Reputation points
    2023-03-14T18:20:38.1066667+00:00

    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.

    0 comments No comments

  2. ajkuma 22,081 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.

    0 comments No comments