Tuesday, September 18, 2012

Error cannot access a closed file – FileUpload in ASP.NET


This was very interesting error, i got during development of file upload control in ASP.NET.
On my local system, every thing was just fine. but when i deployed my application on development server, my control was able to upload only small size files.
whenever i tried to upload large size file i got error “cannot access a closed file”
After going through MSDN i found that there is one new element added in ASP.NET 2.0 known as httpRuntime.
So i just added this new Tag in my web.config and every thing was right.


<system.web>
<httpRuntime  maxRequestLength="15360" requestLengthDiskThreshold="15360"/>
</system.web>

Note :

requestLengthDiskThreshold should not exceed the maxRequestLengthattribute.

To read more about this, please visit http://msdn.microsoft.com/en-us/library/e1f13641(VS.80).aspx

No comments: