I know that this problem has a solution in stackoverflow, but it didn't work for me. I will be more specific below:
I had typical Maximum request length exceeded exception:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.
That's my changes to web.config, under system.web:
<httpRuntime maxRequestLength="200000" executionTimeout="300" />
and under system.webServer:
<security>
<requestFiltering allowDoubleEscaping="false">
<requestLimits maxAllowedContentLength="200000000" />
</requestFiltering>
</security>
I also made this changes in applicationHost.
On one machine these worked like charm. That was windows 7 + iis 7.5. But on another with windows server 2008 + iis 7.0 I cannot get upload of 19 MB to work. I really dont know what to do now. Please help anyone.
OK. That machine was client's machine. Apparently he changed something in IIS manager regarding one of the site's subfolders and IIS manager created web.config in subfolder that was overriding my setting in parent.
Related
I need to test a file upload component that will be accepting very large files. I want to test locally in my development environment but since I use IIS Express instead of IIS 7 I am not sure where to make the global change.
In IIS 7 the change cannot be made via the web.config but needs to be changed through the IIS Manager Tool. See this IIS article for an example.
Does anyone know how to make the same global change using IIS Express (in Visual Studio 2013)?
If the web.config change ppascualv suggested doesn't work, try putting it in the IIS Express applicationhost.config, which can be found at
%userprofile%\my documents\iisexpress\config\applicationhost.config
under
<system.webServer>
put
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000"/>
</requestFiltering>
</security>
This should set it as a global, unless a web.config from an application overrides it.
You basically need to set both in web.config maxRequestLength and maxAllowedContentLength to upload files.
maxRequestLength Indicates the maximum file upload size supported by ASP.NET
maxAllowedContentLength This specifies the maximum length of content in a request supported by IIS.
Note:maxRequestLength is in kilobytes & maxAllowedContentLength is in Bytes
By default, Machine.config is configured to accept HTTP Requests upto 4096 KB (4 MB) and it is reflected in all your ASP.NET applications. You can change the Machine.config file directly, or you can change only the Web.config file of the application(s) you want to
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000"/>
</requestFiltering>
</security>
</system.webServer>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
As others mentioned already you need to modify applicationhost.config and put into it
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000"/>
</requestFiltering>
</security>
What other people didn't mention is that when you are running your web app from Visual Studio, the location of applicationhost.config in the root directory of your project is
.vs\{your_project_name}\config\applicationhost.config and this is the file you will need to modify
You can use this in web.config
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000"/>
</requestFiltering>
</security>
</system.webServer>
Working to get around the "400 Bad Request" due to request headers that are too big, against the Visual Studio 2019's default IIS Express instance, I couldn't get Sarah's solution to work, but found that the http.sys settings here did the trick.
Specifically, I created inside HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters a DWORD registry value called MaxRequestBytes and setting it to a large enough value. For me, 33000 was enough. Also created MaxFieldLength in the same place, and set it to 33000. A machine reboot is mandatory for the setting to become effective.
As for the cause of my problem, it's described here. It's essentially caused by authentication cookies that get placed inside the request headers. Pushing to an Azure App Service works just fine (the limit for the headers there is probably 32KB), but against the local IIS Express, it failed continuously, until the fix described above.
Everything was working just fine...then one time running the debugger and I'm given a 401.2 error from IIS Express 7.5. I created a new project and tested - worked fine. I ensured the web.config and other project settings where identical - still getting the error in the original project!
(I actually resolved this issue...but haven't seen documentation for this exact issue with my resolution anywhere, I'll add the answer momentarily...Yes, I already reviewed other 401.2 questions on Stackoverflow (and elsewhere) and they are not the same as the issue I was facing...)
In my case, for some reason VS 2011 added a few lines to my applicationhost.config file located under Documents\IISExpress\config. The lines added (and which I removed) where as follows:
<location path="IRFEmpty">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
Don't ask me how they got there - I didn't add them. It is pretty annoying, since all the code in my VS project was 100% correct, it was the IISExpress configuration wrong.
Enable AnonymousAuthentication on the web project... See these instructions for enabling WindowsAuthentication EXCEPT in the same place you can enable AnonymousAuthentication: IIS Express Windows Authentication
In VS2011, debugging my MVC project was working until this setting mysteriously changed to "Disabled" and I began receiving 401.2 error. Enabling this setting fixed the problem.
We have one of our sites hosted externally, and all of our internet access is through a proxy.
We've found that this remote site (ASP.NET 4.0, IIS 7.5, Server 2008 R2) doesn't work on most of our domain machines due to the "Use HTTP 1.1 through proxy connections" setting not being set in IE9 - the ScriptResource.axd pages get garbled and come out as illegible characters. (WebResource.axd and all other calls are fine).
We can fix this internally, but are worried that other users may have the same problem, so my question is: is there a setting that controls how ScriptResource.axd is served by IIS that we can change to alleviate this?
I eventually found the the 64-bit ScriptResource.axd handler was sending compressed data whether the browser could handle it or not.
The fix was to add this to the web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<urlCompression doDynamicCompression="false" />
</system.webServer>
I have a page on my ASP.NET site which uploads files.
I have attempted to tweak the web.config file to allow for larger uploads.
In my web.config, I set:
<httpRuntime maxRequestLength="2097152" executionTimeout="3600" />
On my page, when I attempt to upload smaller files, no issue...even at 25MB.
However, when I attempt to upload a 50MB file, I still get a 404 error page.
NOTE: I have a flash control on a different page which can upload almost 2gb with no issues, using this same web.config setting.
Same result on different PCs, same result when posted to different web servers.
My web server is Windows Server 2008 R2.
Any ideas of the cause? Why would flash be ok, but plain jane upload control have this problem?
I found the answer. Windows Server 2008 R2 is using IIS7 (of course), and in IIS7, you have to set the following in your web.config file (in my example to increase the limit to 2gb):
<system.webserver>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
<system.webserver>
This worked, when everything else didn't. IIS7 by default limits uploads to 30mb unless this override is set.
The executionTimeout applies only if the debug attribute in the compilation element is False. (see also http://msdn.microsoft.com/en-us/library/e1f13641.aspx)
So try it when starting your application in Release config.
On an ASP.NET Web Application I have an upload file functionality. I'm restricting the file size up to 10 MB by configuring the inside web.config the maxAllowedContentLength attribute. (I'm using IIs 7.0 BTW).
It get the desired HTTP Error when I access the application from the local machine:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.
When I access the application from another machine I get
The connection was reset
The connection to the server was reset while the page was loading.
How can I get a more descriptive error when my application is accessed remotely?
Thanks,
Maria.
Just ran into this myself. I got the "connection to server reset error" when trying to upload a 40 MB file after setting the maxRequestLength to 50384. I did not get the 404.13 error that is commonly referenced for the issue.
In addition to the httpRuntime web.config setting IIS 7 has a default request filtering limit of 30 MB that can be overridden. Below is my example for how to edit your web.config to allow uploading 50 MB files on IIS 7:
<system.web>
<httpRuntime requestValidationMode="2.0" enableVersionHeader="false" useFullyQualifiedRedirectUrl="true" maxRequestLength="50384" executionTimeout="3600" requestLengthDiskThreshold="1200"/>
...
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="60000000"></requestLimits>
...
Hey I was having a the same problem. I put in both of these attributes and it worked for me. If someone has an explanation that would be awesome.
<httpRuntime maxRequestLength="102400" executionTimeout="3600" />
http://msdn.microsoft.com/en-us/library/e1f13641(VS.71).aspx
Regards,
Kieran