title: Download and Redirect
body: <p>I would like to download a .CSV and redirect the user to another page.</p>
  
  <p>This is my code</p>
  
  <pre><code>    protected void btnExport_Click(object sender, EventArgs e)
      {
          string attachment = "attachment; filename=" + Request.QueryString["exportName"] + ".csv";
          HttpContext.Current.Response.Clear();
          HttpContext.Current.Response.ClearHeaders();
          HttpContext.Current.Response.AddHeader("content-disposition", attachment);
          HttpContext.Current.Response.ContentType = "application/ms-excel";
  
          //CODE TO WRITE CSV
          List&lt;Company&gt; companies = (List&lt;Company&gt;)Session["SelectedCompanies"];
          foreach (Company company in companies)
          {
              HttpContext.Current.Response.Write(company.Name + ";");
              HttpContext.Current.Response.Write(Environment.NewLine);
          }
  
  
  
          HttpContext.Current.Response.Redirect("otherpage.aspx", true);
  
  
      }
  </code></pre>
  
  <p>But unfortunatly, it does only the redirect and not the download of the .CSV.</p>
  
  <p>And if I replace <code>HttpContext.Current.Response.Redirect("otherpage.aspx", true);</code> by <code>HttpContext.Current.Response.End();</code>, then it does only the download of the .CSV and not the redirect.</p>
  
  <p>But I would like to have both.</p>