I have my ASP.NET WebAPIs hosted on IIS 7.5+ which has default Max allowed content length set to 30000000 Bytes.
When I am opening Request Filtering
feature of my webAPI on IIS and check the entry there, it says 30000000 Bytes, but when I am doing upload for files larger than 4MB to the webAPI it is throwing exception as below.
Message "Maximum request length exceeded."
Stack Trace:
at System.Web.HttpBufferlessInputStream.ValidateRequestEntityLength() at System.Web.HttpBufferlessInputStream.GetPreloadedContent(Byte[] buffer, Int32& offset, Int32& count) at System.Web.HttpBufferlessInputStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state) at System.IO.Stream.b__d(Stream stream, ReadWriteParameters args, AsyncCallback callback, Object state) at System.Threading.Tasks.TaskFactory`1.FromAsyncTrim[TInstance,TArgs](TInstance thisRef, TArgs args, Func`5 beginMethod, Func`3 endMethod) at System.IO.Stream.BeginEndReadAsync(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at System.Web.Http.WebHost.SeekableBufferedRequestStream.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Net.Http.HttpContentMultipartExtensions.d__8.MoveNext()
Files smaller than 4MB are getting uploaded fine.
Any idea what places I should be looking for to see where this limit is set?
What I have Tried:
I have checked Server's Web.config, machine.config as well as all the application's web.config, but don't see any entry for size limit anywhere.
I have also tried setting up the entries in webAPI's web.config - maxRequestLength
and maxAllowedContentLength
files as mentioned in various other questions that ask for increasing the size limit for file upload. On doing that Request Filtering Feature in IIS was showing me new value but I was still getting the same exception for files larger than 4MB.