I had to edit the C:\Windows\System32\inetsrv\config\applicationHost.config file and add <requestLimits maxAllowedContentLength="1073741824" /> to the end of the...
And just in case someone's looking for a way to handle this exception and show a meaningful explanation to the user (something like "You're uploading a file that is too big"):
//Global.asax
private void Application_Error(object sender, EventArgs e)
{
var ex = Server.GetLastError();
var httpException = ex as HttpException ?? ex.InnerException as HttpException;
if(httpException == null) return;
if(httpException.WebEventCode == WebEventCodes.RuntimeErrorPostTooLarge)
{
//handle the error
Response.Write("Too big a file, dude"); //for example
}
}
If you can't update configuration files but control in full the code that handles uploaded files use HttpContext.Current.Request.GetBufferlessInputStream(true).
The true value for disableMaxRequestLength parameter tells the framework to ignore configured request limits.
To summarize all the answers in a single place:
Rules:
Notes:
more info MSDN
I had to edit the
C:\Windows\System32\inetsrv\config\applicationHost.config
file and add<requestLimits maxAllowedContentLength="1073741824" />
to the end of the...section.
As per This Microsoft Support Article
I can add to config web uncompiled
The maximum request size is, by default, 4mb (4096 KB)
This is explained here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;295626
The above article also explains how to fix this issue :)
And just in case someone's looking for a way to handle this exception and show a meaningful explanation to the user (something like "You're uploading a file that is too big"):
(ASP.NET 4 or later required)
If you can't update configuration files but control in full the code that handles uploaded files use
HttpContext.Current.Request.GetBufferlessInputStream(true)
.The
true
value fordisableMaxRequestLength
parameter tells the framework to ignore configured request limits.For detailed description visit https://msdn.microsoft.com/en-us/library/hh195568(v=vs.110).aspx