I have a similar problem. The file size limit is set high on our site, but I get timeouts if it takes longer than a couple of minutes to upload the file. Do not want to catch the error, but rather make a setting change to avoid it.
How do I write some errror checking code in my code behind to handle this error? Instead of keep increasing this number, I want to put out a friendly message to the user about the max size. How do I do that?
you can check the file lenght of the file that the user is trying to post to the server then display your message
try
{
if(fileToBeUploaded > constantMaximumFileSize)
{
//display your pretty message here
messageLabel.Text = "Hey! You can't upload a file more than " +
+ constantMaximumFileSize;
}
else
{
//do your upload code here
}
}
catch(HttpException httpEx)
{
//HttpExceptions is an exception that occurrs during the processing of HTTP requests
}
There are 3 other places you can check and adjust the timeout.
IIS --> Select your Virtual Directory ->Right Click for Properties --> Select Virtual Directory Tab-->Click on Configuration--> Select Options Tab --> Change the default TimeOuts for Session and ASP Script Time out
I think default is 20 and 90 seconds respectively.
In ASP.NET, you can write ScriptTimeOut = xxx seconds as you desire.
I'm not the IIS admin so I can't really make any changes on the server. In addition, I do not want to keep increasing the size because there is always a user who will try to upload a bigger size file.
You do not need to increase the size everytime, if you are using .NET 1.1 then you can put the max size which is 1GB if 2.0 then 2GB, I doubt that any user will try to upload in GB. It will not hurt you to put the max allowable size.
My Signature: Mark a post as answered if it helped you, or don't, it makes no difference to me. Just PLEASE try not to use the word "random" when describing your problem.
FileUp Standard Edition can accept uploads of up to 4 gigabytes. FileUp Enterprise Edition can accept unlimited size uploads. However, when using the product in .NET, it is important to configure the application settings to make sure ASP.NET doesn't block
the large uploads before FileUp can process them.
The maxRequestLength parameter is set in the httpRuntime section of web.config (or machine.config). maxRequestLength is set in kilobytes. So, for example, if you want to allow uploads of 100 MB, you would set maxRequestLength to 102400.
There are some other settings in httpRuntime which you may want to modify for large uploads. Below is an example httpRuntime element. Please adjust the settings according to the needs of your application.
To catch the exception you will need to create a Global.asax file in your root directory, then add the method void Application_Error(object sender, EventArgs e) . The Global.asax file handles all the Application level events for your website... the Application_Error
method will catch all the unhanded exceptions generated by your website.
#1 05-21-2002, 06:37 PM Mark Riordan Posts: n/a Solution to "Maximum request length exceeded." -------------------------------------------------------------------------------- When making a large post, you may see the message: Maximum request length exceeded
There are no references to this on MS's website, or anywhere else that I've seen. However, with the help of the Wrox book "Professional ASP.NET", I have found that by default there is a 4MB post limit. This can be changed in machine.config (entire site) or
web.config (individual app), by changing maxRequestLength: The above example increases the limit to 51200 KB (50 MB).
What's the good if we have this default limit for web services if there is not much documentation supporting its modification? I am aware it's for DoS attacks
I added the below to my web.config file because some of the grid reports were encountering th error when a second qery was performed on the data. I noticed this only occurred when the gridview contained thousands of rows. This seting resolved my issues.
None
0 Points
61 Posts
Maximum request length exceeded
Jul 07, 2006 02:56 PM|tuzojazz|LINK
Hi:
I created an asp.net to upload files.
My code is written in visual basic.net
When I try to upload a file bigger than my
maxRequestLength setting I get this exception:
(0x80004005): Maximum request length exceeded.
I can not catch the exception even using try-catch-finally
Is there a way to catch this exception?
Thanks!!
None
0 Points
61 Posts
Re: Maximum request length exceeded
Jul 07, 2006 05:26 PM|tuzojazz|LINK
sorry the esception is
HttpException (0x80004005): Maximum request length exceeded.
Member
10 Points
33 Posts
Re: Maximum request length exceeded
Jan 05, 2007 11:11 PM|vishwa|LINK
You can find the answer on following link
http://www.vishwamohan.com/ShowArticle.aspx?ArticleID=18
Member
54 Points
907 Posts
Re: Maximum request length exceeded
Jan 07, 2007 04:14 AM|erdsah88|LINK
Member
542 Points
191 Posts
Re: Maximum request length exceeded
Jan 13, 2007 05:36 AM|Marian Kostal|LINK
You can set maximum request length in web.config
None
0 Points
3 Posts
Re: Maximum request length exceeded
Feb 09, 2007 10:32 AM|aarenz|LINK
I have a similar problem. The file size limit is set high on our site, but I get timeouts if it takes longer than a couple of minutes to upload the file. Do not want to catch the error, but rather make a setting change to avoid it.
Participant
1221 Points
548 Posts
Re: Maximum request length exceeded
Feb 10, 2007 01:44 AM|ShailAtlas|LINK
Member
269 Points
3818 Posts
Re: Maximum request length exceeded
Apr 10, 2007 11:59 AM|mychucky|LINK
How do I write some errror checking code in my code behind to handle this error? Instead of keep increasing this number, I want to put out a friendly message to the user about the max size. How do I do that?
None
0 Points
55 Posts
Re: Maximum request length exceeded
Apr 10, 2007 02:48 PM|keith.rull|LINK
you can check the file lenght of the file that the user is trying to post to the server then display your message
-
My Personnal Site | DevPinoy.org: A Filipino Developers Community
Member
269 Points
3818 Posts
Re: Maximum request length exceeded
Apr 10, 2007 03:53 PM|mychucky|LINK
Member
10 Points
33 Posts
Re: Maximum request length exceeded
Apr 10, 2007 08:30 PM|vishwa|LINK
Try the following link and see if that can resolve the issue.
http://www.vishwamohan.com/Default.aspx?ArticleID=23
There are 3 other places you can check and adjust the timeout.
IIS --> Select your Virtual Directory ->Right Click for Properties --> Select Virtual Directory Tab-->Click on Configuration--> Select Options Tab --> Change the default TimeOuts for Session and ASP Script Time out
I think default is 20 and 90 seconds respectively.
In ASP.NET, you can write ScriptTimeOut = xxx seconds as you desire.
Member
3 Points
32 Posts
Re: Maximum request length exceeded
Apr 11, 2007 05:45 PM|davidlars99|LINK
Try this: http://www.frozendev.com/temp/fileupload.zip
You can do anything once you get out of the while loop...
Member
269 Points
3818 Posts
Re: Maximum request length exceeded
Apr 13, 2007 10:16 AM|mychucky|LINK
Member
3 Points
32 Posts
Re: Maximum request length exceeded
Apr 13, 2007 05:32 PM|davidlars99|LINK
mychucky, sample project from my web site doesn't require you to be an admin and modify anything in IIS.
Have you actually tried it..?
Member
10 Points
33 Posts
Re: Maximum request length exceeded
Apr 13, 2007 10:08 PM|vishwa|LINK
Member
3 Points
32 Posts
Re: Maximum request length exceeded
Apr 16, 2007 10:18 AM|davidlars99|LINK
OK. I'm going to repeat this one more time...
In .NET 1.1, there's only one (correct way) way to do this.
In .NET 2.0, this limitation issue has been taken care of...
You can see .NET 1.1 example of a workaround here. In this example, there's also a commented code, implementing the wrong way --> http://www.frozendev.com/temp/FileUpload
And you can also see what Microsoft did to fix this issue --> http://support.microsoft.com/kb/910436
Good luck!
Participant
1985 Points
598 Posts
Re: Maximum request length exceeded
Sep 15, 2007 01:30 PM|danludwig|LINK
http://blogs.neudesic.com/blogs/john_watson/archive/2007/05/17/6875.aspx
I can't get this to work in Cassini (Visual Studio built-in testing server), but I can get it to work on production IIS:
Server.ClearError();
Response.Redirect(string, false);
None
0 Points
1 Post
Re: Maximum request length exceeded
Jan 30, 2008 07:17 AM|Muhammad Ejaz|LINK
FileUp Standard Edition can accept uploads of up to 4 gigabytes. FileUp Enterprise Edition can accept unlimited size uploads. However, when using the product in .NET, it is important to configure the application settings to make sure ASP.NET doesn't block the large uploads before FileUp can process them.
The maxRequestLength parameter is set in the httpRuntime section of web.config (or machine.config). maxRequestLength is set in kilobytes. So, for example, if you want to allow uploads of 100 MB, you would set maxRequestLength to 102400.
There are some other settings in httpRuntime which you may want to modify for large uploads. Below is an example httpRuntime element. Please adjust the settings according to the needs of your application.
For more information about various ASP.NET application settings which apply to large uploads, see the FileUpEE or FileUpSE documentation:
FileUpEE - Large Uploads in ASP.NET:
http://support.softartisans.com/docs/fileupeev4/doc/dotnet/aspdotnet_largeuploads.asp
FileUpSE - large uploads in ASP.NET:
http://support.softartisans.com/docs/fileupv4/prog_g_dotnet_largeuploads.htm
None
0 Points
2 Posts
Re: Maximum request length exceeded
Jul 18, 2008 02:47 PM|lali0022|LINK
e) lai0022@gmail.com
Member
40 Points
42 Posts
Re: Maximum request length exceeded
Oct 17, 2008 03:58 AM|anubha.saxena|LINK
#1 05-21-2002, 06:37 PM Mark Riordan Posts: n/a Solution to "Maximum request length exceeded." -------------------------------------------------------------------------------- When making a large post, you may see the message: Maximum request length exceeded There are no references to this on MS's website, or anywhere else that I've seen. However, with the help of the Wrox book "Professional ASP.NET", I have found that by default there is a 4MB post limit. This can be changed in machine.config (entire site) or web.config (individual app), by changing maxRequestLength: The above example increases the limit to 51200 KB (50 MB).
Member
2 Points
45 Posts
Re: Maximum request length exceeded
Jan 12, 2009 06:51 PM|legz11|LINK
I am having a similar problem consuming a web service
I consume the java web service in my .net console app using proxy classes "add web reference"
all's well until the response size is large, or it's taking a little while longer to process
I have failed to find a solution to extending the max request size of the response accepted and/or timeout value?
I have tried adding httpRuntime maxresponsesize to app.config - no luck
I have tried microsoft.web.services3 section
<section
name="microsoft.web.services3"
type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
plus
<configuration>
<microsoft.web.services3>
<messaging>
<maxMessageLength value="-1" />
</messaging>
</microsoft.web.services3>
</configuration>
This didn't do the job either
What's the good if we have this default limit for web services if there is not much documentation supporting its modification? I am aware it's for DoS attacks
Member
23 Points
264 Posts
Re: Maximum request length exceeded
Feb 03, 2009 02:39 PM|gogginl|LINK
I added the below to my web.config file because some of the grid reports were encountering th error when a second qery was performed on the data. I noticed this only occurred when the gridview contained thousands of rows. This seting resolved my issues.
<httpRuntime maxRequestLength="32768" />