Posting data to a HttpHandler greater then ~29MB gives a 404 error - asp.net

I am testing a HttpHandler that accepts XML. It works fine when a small amount of data is posted but if I post data larger then approx 29mb, I get a asp.net 404 Error.
I am posting to the handler from another handler in the same project and I have tried 2 methods -
1. HttpWebRequest with "POST"
2. WebClient with UploadFile() and UploadData()
I get the same 404 error when the posted data is above 28.6 MB.
I also tried putting a breakpoint right in the beginning of the receiving handler and debugging. It is never hit. Appears like the handler was never called. Works ok for smaller sized data.
I already have the following setting. What am I doing Wrong?
<httpRuntime maxRequestLength="1048576" />
EDIT: I have also tried posting to a different handler that doesnt not consume posted data, just to test, but the results are the same.
Environment: Win 7, IIS 7.5, .net 3.5, VS 2008
alt text http://img401.imageshack.us/img401/4099/errormr.png

I discovered that the problem is with IIS 7 and above. It requires the max request length to be set in a different place.
See the following links -
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22943810.html
http://msdn.microsoft.com/en-us/library/ms689462%28VS.90%29.aspx
The default value is 30000000. which is 28.6mb. The correct way to set in web.config is -
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824"></requestLimits>
</requestFiltering>
</security>
</system.webServer>
This config cleared the error I was getting. I wish the errors reported were more descriptive, at least on local machines
Does this mean that setting <httpRuntime maxRequestLength="1048576" /> is enough for IIS 6 ? (the live server is win2003)

Try to add this section to the web.config file:
<location path="YourHandler.aspx">
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
</system.web>
</location>
assuming you handler path is YourHandler.aspx.

Related

RadAsyncUpload Maximum File Size

I have been asked to write an application that basically moves files from a source (USB, CD) to a centralized location. Initially this application will be for internal use only but in the future may be needed by remote users. The files I need to move can be in excess of 4-5Gb. It has been suggested I use the Telerik RadAsyncUpload component. Can anyone tell me if I am likely to run into problems trying to upload files of this size using this control?
To allow larger uploads the maxRexquestLength and executionTimeout needs to be added to your web.config:
<system.web>
<httpRuntime targetFramework="4.5" maxRequestLength="5242880" executionTimeout="10800" />
</system.web>
The trickiest part of having this work is that the execution timeout may exceed the upload time required. So set it higher based on your average users bandwidth. We monitor this by logging when the execution timeout occurs and adjusting as needed periodically. Since your app will be internally initially this probably won't be an issue at all if they are transferring over the LAN.
Further info on this is available in the Telerik documentation here.
There are 3 parts on setting the size of the file that could be uploaded through RadAsyncUpload:
1) Setting the file size in the telerik control
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="100000000" />
</requestFiltering>
</security>
2)Configures ASP.NET HTTP runtime settings, to allow the http Request message to be able to include your file. Here we need to set the maxRequestLength and executionTimeout accordingly.
<system.web><httpRuntime targetFramework="4.5" maxRequestLength="102400" executionTimeout="2147483647" /></system.web>
3)IIS server would generally allow only 30MB of file to be uploaded. To be able to upload larger files, we need to make some other settings in the web.config , to increase the request limits.
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="100000000" />
</requestFiltering>
</security>

I'm getting runtime error for asp.net application, is it timeout issue?

I'm getting this runtime error sometime when I try to use asp.net application.
I'm getting this error when my browser windows is open for long time and I does not work on this.. might be server time
Is it because of login timeout ?
I do not believe there is any way to tell from this error message what the problem is. As the error message states, the current settings prevent the actual error message from being displayed! You need to change the settings so you can actually see the error message, that will help you figure out what is causing it.
To do that, go into your web.config file and set (Note Off has capital O)
On IIS6:
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/> <---- Optional
</system.web>
</configuration>
On IIS7:
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>
Edit - adding some more information:
Hi ashuthinks, I see you have accepted my answer already, but just wanted to add a few more lines. If everything in your code is fine, and the website runs perfectly, and you only get an error message on your screen if you leave it idle for 20 minutes or so, it is possible you are hitting the session timeout. I don't have any experience with this, but I have heard of it happening.
One of the things you can try is to change the session timeout in your web.config :
There seems to be a nice article about this here: http://www.simon.kaulius.com/page_timeout_in_asp_net.htm
It talks about modifying web.config, and making changes in IIS and global.asax to redirect the user to another page on timeout.
There alsoseems to be a thread dealing with a timeout issue on stackoverflow: Session timeout in ASP.NET

Max querystring length on asp .net 2.0

I am working on ASP .NET version 2.0 and IIS 6. I am calling a pop up aspx page from the main page by calling its URL and passing querystring to it.
For a specific case the length of my querystring exceeds more than 2000 characters. So the pop up screen opens up fine for the first time but whenever there is a postback in that pop up screen, I get a internet connection error.
I am sure this is happening because of the large length of the querystring because it works fine when I reduce the length of querystring.
Is there a way we can increase the maximum allowed length of the querystring passed. Can it be configured through web.config or in some IIS settings.
Following is the approach I use for ASP.Net MVC 4
<system.web>
<httpRuntime maxQueryStringLength="6000" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!--Query String Length-->
<requestLimits maxQueryString="6000" />
</requestFiltering>
</security>
</system.webServer>
REFERENCE
request exceeds the configured maxQueryStringLength when using [Authorize]
WCF says it exceeds maximum query string value while it is not
By default it 2048. Check this post (MSDN). Set maxQueryStringLength in httpRuntime section of your web.config.
Please check the requirements for this on the same post.
Hope this works for you.
Attribute maxQueryStringLength of httpRuntime element is supported only by 4.0 and above.
You have to use IIS settings to control max query string limits.
http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits

asp.net - post file gives 404 page result even though posted file is well under maxRequestLength

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.

Issue with URL length in IIS7 (Windows Server 2008)

i have an issue with url lengths in iis7. If you go to:
http://www.somesite.com/myaccount/login.htm?ReturnUrl=aa2Fmyaccounta2FdefaultaaspxadnoaauserSuppliedIdentifierahttpa3Aa2Fa2Faaaaaaamaapenidacoma2Fadnoaareturnatoasigahandleaa7B633942228855348748a7Da7BaRINLQa3Da3Da7DadnoaareturnatoasigaxSa2FFPGusD7UvskGqfkJq4QtEYjc4fSVFoa2F3sXNwCBteGOBJ8mipo7yLsuSk2hEgLogbzn6SthYb0wY3pBQM1OQa3Da3Daopenidaassocahandleaa7BHMACaSHA256a7Da7B4b051c2ba7Da7ddufPa2BAa3Da3Da7Daopenidaclaimedaidahttpa3Aa2Fa2Faaaaaaaaaopbnidacoma2Faopenidaidentityahttpa3Aa2Fa2Faaaaaaaabcpenidacoma2Faopenidamodeaidaresaopenidansahttpa3Aa2Fa2Fspec
The page will load fine but if you add one more character to the end it will throw an error. This might seem abit picky to you but it's stopping me from using open id on my login form since it returns a long url. One option i did consider was changing the requestFiltering, therefore in my web.config i have the following:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="999999999" maxUrl="999999999" />
</requestFiltering>
</security>
</system.webServer>
But this did not resolve the issue. I'd appreciate it if someone could help. Thanks
nfplee - Are you using Ionics Isapi Rewrite Filter (IIRF) by any chance? I just ran into the same issue where long urls always returns a 404.
If I disable IIRF everything works fine.
This is a limitation of Windows and there is currently no workaround
See this StackOverflow article for more information:
ASP.NET url MAX_PATH limit
You may do something in web.config as follows.
<system.web>
<httpRuntime maxUrlLength="4000"/>
</system.web>

Resources