title: Download a string as a file
body: <p>When the user clicks a button, I want to build a string, then have the user download that string as a file (it's a CSV file).</p>
  
  <pre><code>    var response = HttpContext.Current.Response;
      response.ClearContent();
      response.Clear();
      byte[] bytes = Encoding.ASCII.GetBytes(csvtext);
      using (var stream = new MemoryStream(bytes))
      {
          response.AddHeader("Content-Disposition", "attachment; filename=somefile.csv");
          response.AddHeader("Content-Length", stream.Length.ToString());
          response.ContentType = "text/plain";
          stream.WriteTo(response.OutputStream);
      }
  </code></pre>
  
  <p>This is what I have so far, and I have a feeling I'm pretty close, but I get the following error message:</p>
  
  <p>Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
  Details: Error parsing near '[The first bit of the CSV file]'.</p>
  
  <p>I'm at a loss, and a deadline is fast approaching.  Any help is greatly appreciated.</p>