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.

<httpRuntime  maxRequestLength="15360" requestLengthDiskThreshold="15360"/>

Note :

requestLengthDiskThreshold should not exceed the maxRequestLengthattribute.

To read more about this, please visit




Related Posts


16 responses to “cannot access a closed file – FileUpload in ASP.NET”

  1. […] the file size limitation, please visit this article :   No […]

  2. Ranjit Avatar

    no i have putted in my web.config but not working

    1. Shashi Avatar

       plz check dude

  3. Flemming Avatar

    Thanks! 😀 requestLengthDiskThreshold=”15360″ fixed the problem

  4. Manisha Sherla Avatar
    Manisha Sherla

    Thnks… 🙂

  5. pranay Avatar

    Thanks, It’s Working…………….

  6. Ismael Hernández Keps Avatar

    Tanks man…. Excellent… fixed the problem…

  7. Avinash Joshi Avatar
    Avinash Joshi

    Thanks it solved my Problem

  8. shashi Avatar

    Thank you very very much . it solved my problem , Can u explaine the logical concept behind this

  9. Anderson Mariani Avatar
    Anderson Mariani

    The guy you saved my life Thanks

    Anderson Mariani from Brazil

  10. Diego Gonçalves Avatar
    Diego Gonçalves

    Yes! Brazil is very Hot IT. Thanks

  11. vadimdb Avatar

    Thanks a lot!

  12. nitths Avatar

    Thank you. I finally solved the problem… The strange thing was that the error occourred also with small files (a 200KB PNG image). I only had a value (104857) for the first attribute (maxRequestLength) in my web.config, but not for the second. I added it with the same value and… everything’s working now.

  13. Leandro Avatar

    It worked for me! Thanks very much! You are the guy!

  14. Gerardo Aguero Avatar
    Gerardo Aguero

    It works
    Thank you very much!!

  15. Ed Eaglehouse Avatar

    Just having the tag is not enough. You must provide a value for requestLengthDiskThreshold (up to maxRequestSize). Default is 80 KB, but if you don’t explicitly set the value, the framework closes the stream after it buffers the first chunk.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading