Our ASP.NET C# web application is used in the following environment - .NET Framework 4 - IIS 7 - Windows 2008 - Visual Studio 2010 .NET IDE - C# - HTTPS ( SSL ) Our ASP.NET C# web application uploads various files like jpgs, mp4, mp3, pngs, docx, txt, etc
to a folder called ClientBin. However, if we deploy the application to an IIS7 server, we have to give the web user of our application permission to upload file. We give the \IIS_IUSRS group permission to execute, read, write and execute on our ClientBin upload
folder.
A web user can upload files that have size less than approximately 12MB.
However, when a web user uploads any more than approximately 12MB, the file that gets uploaded will be 0 bytes on the server's ClientBin upload folder.
In our Web.config, we have the following configurations for httpRuntime tag:
In IIS 7, I clicked on the website and expanded it then clicked the ASP icon.
Expand the Limits Properties icon, and change the value in the “Maximum Requesting Entity Body Limit” to a value larger than 200000 (which is about 200kb). 4194304 would be about 4 Mb, 41943040 would be 40 Mb.
Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?
Do you have any logic to prevent a user from uploading a file larger than 12mb? If not, then the file object is probably being created before the server check for the restriction. I'd check the file size in your code before calling the save function.
My implementation follows the poor practice of loading the entire file into the Session variable.
However, even though it is poor practice, I decided to continue using it because it would take me
time to reimplement the code in such a way that I uploaded the file into a temporary directory as
opposed to the Session variable.The following modifications in web.config provided the solution.
Try increasing requestLengthDiskThreshold
Also, ensure that requestLengthDiskThreshold matches maxRequestLength
<configuration>
<system.web>
<!-- maxRequestLength and requestLengthDiskThreshold is in Kilobytes-->
<httpRuntime maxRequestLength="204800" requestLengthDiskThreshold="204800" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- maxAllowedContentLength is in Bytes not Kilobytes -->
<requestLimits maxAllowedContentLength="204800000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
alanonymous1...
0 Points
3 Posts
Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?
Nov 30, 2012 03:11 PM|LINK
Our ASP.NET C# web application is used in the following environment - .NET Framework 4 - IIS 7 - Windows 2008 - Visual Studio 2010 .NET IDE - C# - HTTPS ( SSL ) Our ASP.NET C# web application uploads various files like jpgs, mp4, mp3, pngs, docx, txt, etc to a folder called ClientBin. However, if we deploy the application to an IIS7 server, we have to give the web user of our application permission to upload file. We give the \IIS_IUSRS group permission to execute, read, write and execute on our ClientBin upload folder.
A web user can upload files that have size less than approximately 12MB.
However, when a web user uploads any more than approximately 12MB, the file that gets uploaded will be 0 bytes on the server's ClientBin upload folder.
In our Web.config, we have the following configurations for httpRuntime tag:
...........<fileExtensions>I also took the undesired approach of modifying the machine.config file by creating the following settings:
In IIS 7, I clicked on the website and expanded it then clicked the ASP icon.
Expand the Limits Properties icon, and change the value in the “Maximum Requesting Entity Body Limit” to a value larger than 200000 (which is about 200kb). 4194304 would be about 4 Mb, 41943040 would be 40 Mb.
Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?
DarthSwian
Star
12771 Points
2361 Posts
Re: Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?
Nov 30, 2012 03:26 PM|LINK
Do you have any logic to prevent a user from uploading a file larger than 12mb? If not, then the file object is probably being created before the server check for the restriction. I'd check the file size in your code before calling the save function.
Seek and ye shall find or http://lmgtfy.com/
DarthSwian
Star
12771 Points
2361 Posts
Re: Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?
Nov 30, 2012 03:26 PM|LINK
Sorry, hit button twice
Seek and ye shall find or http://lmgtfy.com/
alanonymous1...
0 Points
3 Posts
Re: Why are uploaded files to ASP.NET web Application greater than 12MB being shown as 0MB ?
Dec 11, 2012 07:48 PM|LINK
Also, ensure that requestLengthDiskThreshold matches maxRequestLength
<configuration> <system.web> <!-- maxRequestLength and requestLengthDiskThreshold is in Kilobytes--> <httpRuntime maxRequestLength="204800" requestLengthDiskThreshold="204800" /> </system.web> <system.webServer> <security> <requestFiltering> <!-- maxAllowedContentLength is in Bytes not Kilobytes --> <requestLimits maxAllowedContentLength="204800000" /> </requestFiltering> </security> </system.webServer> </configuration>