4
votes

I am having a HTTP PUT web API method in my MVC application which receives files from client side and Put it to the server storage.

As the file size might be large, I am not streaming the file into the memory to avoid memory out of bound exceptions, thus I am using MultipartFormDataStreamProvider to load it in a temp folder, and move it to final destination later.

Everything works perfectly except the fact that it doesn't upload files larger than 2097148 KB (2.097GB). Once I give a file larger than that it starts streaming it at the Temp folder, and then it stops once the file sizes reaches 2097148 KB.

I have the folloing attributes in my web.config file :

maxRequestLength="5097151",

requestLengthDiskThreshold="50971",

maxAllowedContentLength="4242880000".

Also in IIS I have set the Maximum allowed content length (Bytes) to 4242880000 KB.

Is there anyother place which might cause this to happen?

1
what IIS version are you using?Andrei Rînea
@AndreiRînea, I am using IIS 7.5.Benjamin

1 Answers

4
votes

Update

It seems that even under IIS 10 with .NET 4.6.1 the request is denied (400 Bad Request) even though all the limits are set to allow it.

Digging further it seems that this has been rejected at Microsoft.


In .Net 4.0 and earlier there is a 2Gb limitation in ASP.NET, that was fixed in .Net 4.5. However this fix makes a little sense because IIS itself does not support file uploads over 2Gb.

The only way to upload files over 2Gb to IIS-hosted server is to break it into pieces and upload piece by piece. Here are clients that can upload breaking a file into segments:

  1. IT Hit Ajax File Browser
  2. Sample WebDAV Browser

Note that these clients require your server to support PUT with Range header.

Another solution is to create a HttpListener-based server. HttpListener has much less functionality comparing to IIS but it does not have any upload limitations.


source