title: Export from GridView to Excel save popup not working
body: <p>I want to export data from GridView into an excel file on ASP.NET website. I added a GridView only for this purpose </p>
  
  <pre><code>&lt;body&gt;
     &lt;form id="mainForm" runat="server"&gt;
        &lt;asp:GridView ID="exportGrid" runat="server"&gt;
        &lt;/asp:GridView&gt;
     &lt;/form&gt;
  ....
  &lt;/body&gt;
  </code></pre>
  
  <p>In codebehind I have this:</p>
  
  <pre><code>public override void VerifyRenderingInServerForm(Control control) { }
  
  var result = GetDataIQueryable(); //A method that returns an IQueryable
  exportGrid.DataSource = result; 
  exportGrid.DataBind();
  Response.Clear();
  Response.ClearContent();
  Response.AddHeader("content-disposition", "attachment; filename=" + "ExcelFile.xls");
  Response.ContentType = "application/excel";
  var sw = new System.IO.StringWriter();
  var htw = new HtmlTextWriter(sw);
  exportGrid.RenderControl(htw);
  Response.Write(sw.ToString());
  Response.End();
  </code></pre>
  
  <p>The problem is that the popup that allows me to save the excel file on my computer is not appearing. What should I change in my code ? </p>