0

I am trying to upload large file over 2GB to ASP.NET MVC 5 on IIS. I googled and found that IIS has 2GB http request limit and MS did not have fixed it yet.

I found a workaround using StreamContent class with HttpContext.Current.Request.GetBufferlessInputStream(true) at the following link; (see Priyanka's answer)

Exceeding the 2GB file upload limitation in IIS 7.5 and .NET

I confirmed that it worked if only Content-Length header was not set at http request.

So, I succeeded in uplading a file over 2GB with PostMan where Content-Length header was unchecked.


However, my real world application uploads file with HTML/Javascript and Content-Length header is always set and IIS treats the http request as bad request though I changed web.config.

So, I am finding a way to strip(remove) Content-Length header in http request. I found a hint that it may be possible with IIS Url Rewrite.

Could you pleae let me know how to strip(remove) Content-Length header in http request using IIS Url Rewrite?

Best regards.

Ivoryguard
  • 155
  • 1
  • 8

1 Answers1

0

Some of the requests header we can not modify by using URL rewrite rule or any code. You can try to use the below code to allow iis to upload the larger file:

<requestFiltering>
    <requestLimits maxAllowedContentLength="4294967295"/>
  </requestFiltering>
  <httpRuntime executionTimeout="2400" maxRequestLength="2147483647"/>
Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26
  • Unfortunately, I already have tried it and found it worked if only Content-Length header was not set - maxAllowedContentLength is 4GB Max. and maxRequestLength value is KB and so it becomes 2TB. However, ISAP module of IIS tried to read Content-Length header and it blocks inbound http request as a bad request before my ASP.NET code is executed. please, refer https://stackoverflow.com/questions/13129746/is-there-a-way-to-ignore-the-maxrequestlength-limit-of-2gb-file-uploads – Ivoryguard Dec 08 '22 at 22:23