title: Why does "Cannot access closed file" error show up? And why only on the server?
body: <p>I have a code snippet which uploads an image. On uploading, it temporarily stores the file in a Session. Then on click of "Save", it saves the file in a database.</p>
  
  <p>There's no problem on my machine, but on the server, whenever I try to upload some files, and then click on "Save", it shows me an error "Closed file cannot be accessed". On Googling it, I read <a href="http://shivasoft.in/blog/microsoft/net/cannot-access-a-closed-file-fileupload-in-asp-net/" rel="nofollow">here</a> that this was due to large files being uploaded. I wanted to confirm, is the problem that I'm uploading large files?? Or could it be something else?
  Also, why am I not getting this on my machine and only on the server??</p>
  
  <p>EDIT: By the way, the error showed up when the <code>file size &gt; 80kb</code></p>
  
  <p>Code on Uploading file:</p>
  
  <pre><code>public ActionResult StoreLogoInSession(HttpPostedFileBase file, int assetID)
          {
              string filename = null;
              if (ValidateOnUpload(file))
              {
                  Session.Add("TempLogo", file);
                  filename = file.FileName;
                  Session.Add("filename", filename);
              }
              return RedirectToAction("Edit", new { id = assetID });
          }
  </code></pre>
  
  <p>Code on Saving (this is when the error occurs):</p>
  
  <pre><code>public ActionResult SaveLogo(LogoModel m, int assetID)
          {
                  HttpPostedFileBase file = (HttpPostedFileBase)Session["TempLogo"];
                  var logoModel = new LogoModel();
                  var asset = this.GenerateAssetForUploadFile(file, (int)m.Asset.AccountID, m.Asset.TextContents, m.Asset.AssetName);
                  this.LogoManagementFacade.SaveLogo(asset);
                  logoModel.Asset = asset;
                  this.LogoModelList.Add(logoModel);
  }
  </code></pre>