Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
i am using jquery file upload plugin to upload file. so whenever one upload's a file
i store that file in the session
after storing the file in the session then i am retrieving the files from the session
and storing it .When i try to save file which is more than 10 mb i get this error
"Cannot access closed file"

Here is my c# code
file.SaveAs(Path.Combine(HttpContext.Current.Server.MapPath("~/" + FolderName + "/"), strfilename));


In web config i have done this settings


HTML
<httpRuntime requestLengthDiskThreshold="15360" maxRequestLength="2147483647" useFullyQualifiedRedirectUrl="false"/>

XML
<security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="4294967295" />
      </requestFiltering>
    </security>

Can any one let me know where i am going wrong.
Posted
Updated 1-Oct-15 4:34am
v3
Comments
John C Rayan 1-Oct-15 11:13am    
Are you storing the file content or temporary file path in the session? Try to write the file into a temporary location and then store it into the actual location and see if it solves the issue. What's you execution timeout in web.config?
surajemo 3-Oct-15 9:07am    
execution timeout(httpRuntime) in the web config is 90.
I am storing the file(which we retrieve when write HttpPostedFileBase file = Request.Files[0];) in the session and not the path.
Richard Deeming 1-Oct-15 12:04pm    
Don't try to store the file contents in the session. Just save the uploaded file directly to the folder.
surajemo 3-Oct-15 9:07am    
If nothing works out i have to do that :)
Sreekanth Mothukuru 1-Oct-15 16:49pm    
The file will be posted once to the server.IMO Either store the file in session as memory stream or to the temp location before saving it to DB or file server.

IMO Storing file content as memory stream in a session is not recommended.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900