title: asp.net on button click create CSV file, download it and refresh page
body: <p>Is it impossible to gather information from page (and databaes), create csv file from given information, download created file and <strong>refresh page</strong>?</p>
  
  <p>Currently user sees a table with rows, select rows by checking checkboxes, press Export button and CSV file is created and downloaded to users computer. The problem is with Page Refresh.</p>
  
  <p>Currently on button click CSV is created and downloaded in the following way:</p>
  
  <pre><code>        //here is create csv function and then the result is outputed
          Response.Clear()
          Response.Buffer = True
          Response.AddHeader("content-disposition", "attachment;filename=DataTable.csv")        
          Response.Charset = ""
          Response.ContentType = "application/text"
  
          Response.Output.Write(CsvFile.ToString(), 0)
          Response.Flush()
          Response.End()
  </code></pre>
  
  <p>This soultion makes problems with Page refresh after csv file is downloaded.</p>
  
  <p>1) This link: 
  <a href="https://stackoverflow.com/questions/3676734/redirecting-to-another-page-after-response-end-has-been-called-in-c-sharp">Redirecting to another page after Response.End() has been called in C#</a></p>
  
  <p>suggests `Response.AddHeader("Refresh", "3; url=index.html"); that should refresh page.
  This doesn't work, no redirect happens.</p>
  
  <p>2) Another sollution suggested is creating some additional URL and allow user to download file from given  URL. This doesn't fit my situation, because File is created from data on the page.</p>
  
  <p>3) Is there any other solution that fits needs (button click creates csv and downloads it, page is refreshed)?</p>
  
  <p>Can you give me some clues, please?</p>