FileUpload via Session variable over certain size and get "Cannot access a closed file" error
<p>I created an empty ASP.NET app with 2 pages, Default.aspx and Action.aspx (please see below).  When running, I select a 200k .bmp file and click to save.  I then get a "Cannot access a closed file" error BUT ONLY when my source file is above 55k or so.  What gives?  thanks</p>

<h2>Default.aspx</h2>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %&gt;
&lt;!DOCTYPE html&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head id="Head1" runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
    &lt;asp:FileUpload ID="attachmentFileUpload" Width="300px" runat="server" /&gt;
    &lt;asp:Button ID="saveButton" runat="server" Text="Save" OnClick="saveButton_Click" /&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>Default.aspx.cs</h2>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
    public partial class Simple : System.Web.UI.Page
    {
        protected void saveButton_Click(object sender, EventArgs e)
        {
            Session["AttachmentFileUpload"] = attachmentFileUpload;
            Response.Redirect("Action.aspx");
        }
    }
}
</code></pre>

<h2>Action.aspx</h2>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Action.aspx.cs" Inherits="WebApplication1.Action" %&gt;
&lt;!DOCTYPE html&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>Action.aspx.cs</h2>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
    public partial class Action : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FileUpload tempFileUpload = (FileUpload)Session["AttachmentFileUpload"];
            tempFileUpload.PostedFile.SaveAs(@"C:\Temp\MyUpload.bmp");
        }
    }
}
</code></pre>
