I recently came across a problem when uploading files from an INPUT tag type=file. When I tried to process the uploaded file either using the SaveAs method or by accessing the stream I got an error "Cannot access a closed file" at random. It would always occur for some files but the same file could be uploaded successfully on a different server.
I eventually cleared the problem after much searching on the web by setting two new attributes in the httpRunTime tag in web.config.
These were:
maxRequestLength which should be set to about 50% larger than the largest file you wish to upload. I used 16000 (16MB as the value is in KB). It needs to be quite a bit larger than the maximum file size because it must allow for the rest of the Request including ViewState and for any conversion to Base64 of binary files.
requestLengthDiskThreshold which I set to 8192 (bytes). This was the one that fixed the problem for me. Other values will probably work but the default is stated to be 256 bytes.
Bob Boffin
I eventually cleared the problem after much searching on the web by setting two new attributes in the httpRunTime tag in web.config.
These were:
maxRequestLength which should be set to about 50% larger than the largest file you wish to upload. I used 16000 (16MB as the value is in KB). It needs to be quite a bit larger than the maximum file size because it must allow for the rest of the Request including ViewState and for any conversion to Base64 of binary files.
requestLengthDiskThreshold which I set to 8192 (bytes). This was the one that fixed the problem for me. Other values will probably work but the default is stated to be 256 bytes.
Bob Boffin