title: File download does not work with IE7
body: <p>I have an asp.net page which sends content of a file to the client, so the browser shows the save as dialog to download the file. This page is displayed in a popup and when the user clicks the save button, it closes automatically and the download starts.</p>
  
  <p>On windows server 2003, it works fine. On vista with other browsers, also works fine. But when I try with IE7 &amp; Vista, the popup opens, and closes after about a second without displaying the file download dialog. How can I solve this?</p>
  
  <p>The code I use for response generation is:</p>
  
  <pre><code>FileStream fileStream = new FileStream(filePath, FileMode.Open);
  int fileSize = (int)fileStream.Length;
  
  byte[] buffer = new byte[fileSize];
  fileStream.Read(buffer, 0, (int)fileSize);
  fileStream.Close();
  
  Response.Clear();
  
  Response.Buffer = true;
  Response.BufferOutput = true;
  Response.ContentType = "application / octet - stream";
  
  Response.AddHeader("Content-Length", buffer.Length.ToString());
  Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
  Response.AddHeader("Extension", Path.GetExtension(filename));
  Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254"); 
  Response.BinaryWrite(buffer);
  Response.Flush();
  Response.End();
  </code></pre>
  
  <p>And I am opening the popup with this javascript:</p>
  
  <pre><code>window.open ('Download.aspx?filename=somefile.ext','downloadWindow','location=0,status=0,scrollbars=0,width=1,height=1');
  </code></pre>
  
  <p><strong>EDIT:</strong> I corrected the spaces but unfortunately they are not the problem.</p>
  
  <p><strong>EDIT 2:</strong>: Seems that this problem is not related to Vista but IE only. I also discovered that it works fine when the project is run on the development server locally but when working as connected to publish server, it fails to download the file.</p>