Stefan R.
Stefan R.

Reputation: 448

Uploading big files to dotnetcore app in Azure fails (404)

I can't upload big files and I'm not sure if it's still about a size limitation or about a timeout.

On the controller endpoint, I tried all the attributes I found (at once)

        [HttpPost("[action]")]
        [DisableRequestSizeLimit]
        [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue, BufferBodyLengthLimit = long.MaxValue)]
        [RequestSizeLimit(int.MaxValue)]
        public async Task UploadForm()

During 'ConfigureServices' I also setup this:

      services.Configure<FormOptions>(options =>
        {
            options.MemoryBufferThreshold = int.MaxValue;
            options.ValueLengthLimit = int.MaxValue;
            options.ValueCountLimit = int.MaxValue;
            options.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart
        });

But I still get 404 errors after uploading a part of the file (30 MB are already too much).

Then I even tried setting up the kestrel with the following code, but like that the app doesn't even start (502)

.UseKestrel((KestrelServerOptions o) =>
            {
                o.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(120);
                o.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(120);
                o.Limits.MaxRequestBodySize = null;
            })

Upvotes: 2

Views: 461

Answers (1)

suziki
suziki

Reputation: 14088

have a look of this Offcial doc.

Solution:

Change the value of maxAllowedContentLength.

Add these code in Web.config(under site/wwwroot on Kudu):

<configuration>
   <system.webServer>
      <security>
         <requestFiltering>
            <requestLimits maxAllowedContentLength="<valueInBytes>"/>
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>

This should work without restart.

Upvotes: 4

Related Questions