title: Force download of a file on web server - ASP .NET C#
body: <p>I need to force the initiation of download of a .sql file, when user clicks a button in my  ASP .NET (C#) based web application.</p>
  
  <p>As in, when the button is clicked, a save as dialog should open at the client end...</p>
  
  <p>How do I do this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is the code I am using</p>
  
  <pre><code>        string sql = "";
          using (System.IO.StreamReader rdr = System.IO.File.OpenText(fileName))
          {
              sql = rdr.ReadToEnd();
          }
          Response.ContentType = "text/plain";
          Response.AddHeader("Content-Disposition", "attachment; filename=Backup.sql");
          Response.Write(sql);
          Response.End();
  </code></pre>
  
  <p>This is the error that I'm getting...</p>
  
  <p><a href="http://img40.imageshack.us/img40/2103/erroro.gif">alt text http://img40.imageshack.us/img40/2103/erroro.gif</a></p>
  
  <p>What's wrong?</p>