Integrated Pipeline mode: Uploading file of more than 2GB
Asked Answered
P

0

7

Though I have set the limit of contentlength to around 4GB which is max as below

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="4294967295">
    </requestLimits>
  </requestFiltering>
</security>

<httpRuntime targetFramework="4.5" requestValidationMode="2.0"
  requestPathInvalidCharacters="" maxRequestLength="5024000" executionTimeout="3600" />

I am getting below error

HTTP Error 400.0 - Bad Request

ASP.NET detected invalid characters in the URL.

I found a link which mentions the reason of this behavior

https://blogs.msdn.microsoft.com/friis/2013/06/19/uploading-large-file-to-iis-7-5-or-8-using-file-input-element/

If the application is running under the NET 4.5 Integrated Pipeline, upload will not work above 2G and the following error will be sent by IIS: "HTTP 400.0 – Bad Request ASP.NET detected invalid characters in the URL.".

When the integrated pipeline is used, we go though webengine code (webengine4!MgdGetRequestBasics) which doesn't support more than 2 GB content-length and a System.ArithmeticException exception is raised which subsequently cause the HTTP 400 error. With the classic pipeline, we don't use webengine4 but the old ASPNET_ISAPI model and we don't hit the above issue.

Wanted to ask if this is still valid in IIS 10 and .net framework 4.5.

Is there any setting that can be set to get around this?

Palmitin answered 30/11, 2017 at 4:44 Comment(6)
@PanagiotisKanavos Because I hit this behavior only when uploading file greater than 2GB and the blog clearly mentions this (ff the application is running under the NET 4.5 Integrated Pipeline, upload will not work above 2G and the following error will be sent by IIS: "HTTP 400.0 – Bad Request ASP.NET detected invalid characters in the URL.".)Palmitin
We're seeing this behaviour also when running in an Azure App Service on a .NET Framework version 4.7 with the Integrated pipeline. So I can confirm this still happens. Eager to know if there's a solution though.Adamo
@Jan_v You mean uploading file more than 2 GB?Palmitin
Yes indeed. One of our engineers discovered this yesterday and wondered how/if this can be resolved. Otherwise we'll have to resort to some other mechanism for uploading files, which would be a shame as the software is running for about 6 years already and don't feel like changing it too much at this time.Adamo
There are two approaches: either you compress file to bring the size down or implement chunk file upload using some client side library and aggregate the chunks in the server. Checkout this repo which can basically give you an idea as to how to go about chunk file upload.Palmitin
Too bad. Luckily, we've already implemented this chunk based file upload on a different endpoint, so it's rather easy for us to refactor. But, it'll take more effort compared to changing some configuration parameter. Thanks!Adamo

© 2022 - 2024 — McMap. All rights reserved.