Getting “Cannot access a closed file” errormessage when getting file from session
问题 I have a asp.net FileUpload control. I can successfully upload file to store in session, but when I am tring to get its inputstream (I'm store file in HttpPosterFile) I'm getting error Cannot access a closed file tr.PostedFile //<== HttpPostedFile; byte[] byteArray = null; using (var binaryReader = new BinaryReader(tr.PostedFile.InputStream)) { byteArray = binaryReader.ReadBytes(tr.PostedFile.ContentLength); } 回答1: add this to your web.config file <system.web> <httpRuntime