Challenges in Uploading Files Over 2GB via HTTP Protocol in IIS Web Server

  • Thread starter Thread starter Archi_Chakraborty
  • Start date Start date
A

Archi_Chakraborty

Recently, I had worked on a case where customer`s ask was to upload a file larger than 2gb into the IIS hosted web application.



In my case, customer had a normal Asp.net Framework 4.6 application and when they were trying to perform the upload operation of more than 2gb zip file(the extension did not matter...we tested it with .7z and .zip both and it had failed) and somehow on the browser page, we got a Bad request and when I checked the HAR file, i could see a 400 status code.



Next, I checked the application configurations...like:





system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength

system.web/httpRuntime/executionTimeout

system.web/httpRuntime/maxRequestLength





but these values were already configured for the higher number.



Articles for references:

HttpRuntime.ExecutionTimeout

MaxAllowedContentLength
Request Filtering

HttpRuntime.maxRequestLength



Also, we checked the App Pool Managed Pipeline Mode, and the interesting part was that we got different error for both the modes.



I was able to recreate this scenario in my lab machine for a sample asp.net framework web application and I had captured FREB logs (Failed request tracing logs) for the site for both the scenarios these were the differences I noticed:



  • In both the cases, I was able to upload only 2gb file size.
  • In Integrated Mode, when I tried to upload a 4gb file, I could see this error under the FREB log: "
    400 Bad request-Asp.net detected invalid characters in the Url". So, I tried to increase the value of "maxAllowedContentLength" to the maximum supported value, which is 4gb but still it failed, and it seems that webengine code (webengine4!MgdGetRequestBasics) doesn't support more than 2 GB content-length.

  • Next, in Classic Mode, when I tried to upload a 4gb file, i got this error under FREB log : "413.1 -request entity too large error". So, in this case also, I increased the value of "maxAllowedContentLength" to 4gb, but it failed. We did not see any error under FREB log...it was also 200 status code but the file did not upload.

So, the conclusion is that either you keep the application pipeline mode as Integrated or Classic, you would only be able to upload a 2gb file for your web application hosted on IIS.



If you would like to perform a larger file upload operation, HTTP protocol isn't the right one. You need to switch to webDav feature, or use FTP protocol that is meant to perform the file upload/download operation without any size limit or you can keep using Http protocol but you need to send the data packets as small chunks from client to the server side and then on the server side code, you need to bundle all the chunked packets together for the file upload operation.



Also, note that even if you think moving to latest windows server would fix it...that's not going to help here. This behavior will be same for all the supported IIS across all the versions of supported windows server.


Hope this article helps everyone.
:smile:


Continue reading...
 
Back
Top