ASP.NET strange server error on file download
<p>everyone!
I've got very strange error when trying download zip file, generated on the fly.
On some client computers everything is OK, file downlading perfect, on others there is server exception (I am trying to test using different browsers):</p>

<p>Message:
Object reference not set to an instance of an object
StackTrace:
в ASP.development_detail_aspx.__RenderContent1(HtmlT­extWriter __w, Control parameterContainer) в System.Web.UI.Control.RenderChildrenInternal(HtmlT­extWriter writer, ICollection children) в System.Web.UI.Control.RenderChildrenInternal(HtmlT­extWriter writer, ICollection children) в System.Web.UI.HtmlControls.HtmlForm.RenderChildren­(HtmlTextWriter writer) в System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex­tWriter output) в System.Web.UI.HtmlControls.HtmlForm.RenderControl(­HtmlTextWriter writer) в System.Web.UI.Control.RenderChildrenInternal(HtmlT­extWriter writer, ICollection children) в System.Web.UI.Control.RenderChildrenInternal(HtmlT­extWriter writer, ICollection children) в System.Web.UI.Page.Render(HtmlTextWriter writer) в System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</p>

<p>My code in asp:ImageButton OnClick event. Server is IIS 7.5:</p>

<p>...</p>

<pre><code>using (MemoryStream output = new MemoryStream())
{
    using (ZipOutputStream s = new ZipOutputStream(output))
    {
        s.SetLevel(5); // 0 - store only to 9 - means best compression
        byte[] buffer = new byte[4096];


        foreach (var file in devFiles)
        {
            if (file.PhisicalName != "")
            {
                ZipEntry entry = new ZipEntry(file.RealName);
                s.PutNextEntry(entry);
                using (FileStream streamer = File.OpenRead(HttpContext.Current.Server.MapPath(file.PhisicalName)))
                {
                    int sourceBytes;
                    do
                    {
                        sourceBytes = streamer.Read(buffer, 0, buffer.Length);
                        s.Write(buffer, 0, sourceBytes);
                    }
                    while (sourceBytes &gt; 0);
                } 
            }
        }

    s.Finish();    
    HttpResponse response = HttpContext.Current.Response;
    response.Clear();
    response.ContentType = "application/octet-stream";
    response.AppendHeader("Content-Disposition", "attachment; filename=doc.zip");
    response.AppendHeader("Content-Length", output.Length.ToString());
    response.BinaryWrite(output.ToArray());
    response.End();
    output.Close();
    s.Close();
}
</code></pre>
