Share via

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

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

Developer technologies | ASP.NET Core | Other
Developer technologies | ASP.NET Core | ASP.NET API

2 answers

Sort by: Most helpful
  1. Ajay Kumar N 28,261 Reputation points Microsoft Employee Moderator
    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.

    Was this answer helpful?

    0 comments No comments

  2. Bruce (SqlWork.com) 84,071 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.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.