My asp.net 2.0 application uses the FileUpload control to upload files to a hosted web server. I have modified the web.config to acomodate file upload sizes greater than the default 4mb. The commented portion of the httpRuntime section was my first attempt
and the uncommented one is a simpler version for testing. I can upoad files up to about 4.4mb. When I try a 5.8 mb file, I get the same page I posted from with the error message "Internet Explorer cannot display the webpage".
The FileUpload control on the page is pretty simple: <asp:FileUpload
ID="FileInput"
runat="server" />
The meat of the handler for the upload control Upload button is:
string strBaseFileLoc = Server.MapPath("../docs/");
string serverFileName =
Path.GetFileName(FileInput.PostedFile.FileName);
FileInput.PostedFile.SaveAs(strBaseFileLoc+serverFileName);
Thanks for the reply. The first link is like so many others I have read...same information. The value I have in my current web.config should allow an 11 mb file, but fails on a 5.8 mb file but allows a 4.4 mb file to upload. I have also read the second
link today and back when I first determined I had issues uploading large files. The interesting thing is I was once able to upload large fles (tested a 40 meg file with success). Now I cannot. The code that handles this functionality has not changed. I'm
at a loss.
If there are any other suggestions of different controls like FTP, for example, I'm all ears! I would like to get the one that comes with VS to work though.
You just need to extend your maxRequestLength attribute in web.config.
I have used <httpRuntime executionTimeout="3600" maxRequestLength="1048576"/> in my sample application and I have tried with 6.6 MB file.
But it allows me to upload and it saved successfully.
Please try with this and let me know whether it is done or not ?
Please correct me if my understanding is wrong.
Thanks,
Mitesh.
Please Mark this as an Answer if it resolves your problem.
It turns out my hosting provider has limited web file uploads at the domain level to 5 MB. Whe I initially tested this functionality, I used the temporary URL and it worked. Funny thing is there is no such restriction on the temporary URL. Thanks for
all of your help!
markgmcm
0 Points
4 Posts
FileUpload ignores httpRuntime maxRequestLength limit
Jul 08, 2008 03:07 AM|LINK
My asp.net 2.0 application uses the FileUpload control to upload files to a hosted web server. I have modified the web.config to acomodate file upload sizes greater than the default 4mb. The commented portion of the httpRuntime section was my first attempt and the uncommented one is a simpler version for testing. I can upoad files up to about 4.4mb. When I try a 5.8 mb file, I get the same page I posted from with the error message "Internet Explorer cannot display the webpage".
Any ideas? Thanks in advance! ~Mark
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="false">
<compilers>
<compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".cs" compilerOptions="/d:DEBUG;TRACE"/></compilers>
</compilation>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms name="cscAuthCookie" loginUrl="Login.aspx" timeout="180"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="60"/>
<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
<xhtmlConformance mode="Legacy"/>
<!-- <httpRuntime executionTimeout="10240" maxRequestLength="11264" requestLengthDiskThreshold="80" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000" enableKernelOutputCache="true" enableVersionHeader="true" requireRootedSaveAsPath="true" enable="true" shutdownTimeout="90" delayNotificationTimeout="5" waitChangeNotification="0" maxWaitChangeNotification="0" enableHeaderChecking="true" sendCacheControlHeader="true" apartmentThreading="false"/>-->
<httpRuntime executionTimeout="10240" maxRequestLength="11264" />
</system.web>
</configuration>
The FileUpload control on the page is pretty simple: <asp:FileUpload ID="FileInput" runat="server" />
The meat of the handler for the upload control Upload button is:
string strBaseFileLoc = Server.MapPath("../docs/");
string serverFileName = Path.GetFileName(FileInput.PostedFile.FileName);
FileInput.PostedFile.SaveAs(strBaseFileLoc+serverFileName);
Ahmish
Participant
1084 Points
312 Posts
Re: FileUpload ignores httpRuntime maxRequestLength limit
Jul 08, 2008 04:07 AM|LINK
Try maxRequestLength="200000"
and also check this post
http://weblogs.asp.net/skoganti/archive/2004/02/22/78124.aspx
concept of HttpRuntime Element
http://msdn.microsoft.com/en-us/library/e1f13641(VS.71).aspx
Ahmad Sheikh
Microsoft Valuable Geek :: Freelancer & Consultant
http://sharpcontents.blogspot.com
markgmcm
0 Points
4 Posts
Re: FileUpload ignores httpRuntime maxRequestLength limit
Jul 08, 2008 04:16 AM|LINK
Thanks for the reply. The first link is like so many others I have read...same information. The value I have in my current web.config should allow an 11 mb file, but fails on a 5.8 mb file but allows a 4.4 mb file to upload. I have also read the second link today and back when I first determined I had issues uploading large files. The interesting thing is I was once able to upload large fles (tested a 40 meg file with success). Now I cannot. The code that handles this functionality has not changed. I'm at a loss.
If there are any other suggestions of different controls like FTP, for example, I'm all ears! I would like to get the one that comes with VS to work though.
Thanks,
Mark
Ahmish
Participant
1084 Points
312 Posts
Re: FileUpload ignores httpRuntime maxRequestLength limit
Jul 08, 2008 04:25 AM|LINK
try this link to upload using ftp might it help
http://itfact.blogspot.com/2008/01/how-to-upload-file-to-ftp-server-or.html
Ahmad Sheikh
Microsoft Valuable Geek :: Freelancer & Consultant
http://sharpcontents.blogspot.com
mit_ce
Member
574 Points
91 Posts
Re: FileUpload ignores httpRuntime maxRequestLength limit
Jul 08, 2008 05:26 AM|LINK
Hi,
You just need to extend your maxRequestLength attribute in web.config.
I have used <httpRuntime executionTimeout="3600" maxRequestLength="1048576"/> in my sample application and I have tried with 6.6 MB file.
But it allows me to upload and it saved successfully.
Please try with this and let me know whether it is done or not ?
Please correct me if my understanding is wrong.
Mitesh.
Please Mark this as an Answer if it resolves your problem.
markgmcm
0 Points
4 Posts
Re: FileUpload ignores httpRuntime maxRequestLength limit
Jul 09, 2008 03:42 PM|LINK
It turns out my hosting provider has limited web file uploads at the domain level to 5 MB. Whe I initially tested this functionality, I used the temporary URL and it worked. Funny thing is there is no such restriction on the temporary URL. Thanks for all of your help!