title: Download txt file issue
body: <p>I'm new in .Net development.
  I try to enable downloading txt file:</p>
  
  <p>I use this code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
                  string str = "Test information";
                  byte[] bytes = new byte[str.Length * sizeof(char)];
                  System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
                  MemoryStream mem = new MemoryStream();
                  mem.Write(bytes, 0, str.Length);
  
                  Stream outStream = Response.OutputStream;
                  Response.ContentType = "application/text/plain";
                  Response.AppendHeader("Connection", "keep-alive");
                  Response.AppendHeader("Content-Disposition", " attachment; filename = " + "test.txt");
                  mem.WriteTo(outStream);
                  outStream.Close();
       }
  </code></pre>
  
  <p>But I get text file with bad first string (problems with encoding) and many other strings with information about current page.</p>
  
  <p><strong>Update:</strong>
  Here is the file I get</p>
  
  <pre><code>Bad string
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
  &lt;head&gt;&lt;title&gt;
      ASP.NET AJAX Web Services: Web Service Sample Page
  &lt;/title&gt;
      &lt;script src="../Scripts/jquery-1.3.2.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              $("#MainContent_RegisterUser_CreateUserStepContainer_UserName").blur(function (event) {
                  $.ajax({
                      type: "POST",
                      url: "../About.aspx/validateUser",
                      contentType: "application/json; charset=utf-8",
                      data: "{'username': '" + $(this).val() + "'}",
                      dataType: "json",
                      success: AjaxSucceeded,
                      error: AjaxFailed
                  });
              });
          });
          function AjaxSucceeded(result) {
              if (result.d == "true") {
                  $("#LoginSpan").text("РўР°РєРѕР№ РїРѕР»СЊР·РѕРІР°С‚РµР»СЊ СѓР¶Рµ СЃСѓС‰РµСЃС‚РІСѓРµС‚");
              }
              else {
                  $("#LoginSpan").text("");
              }
          }
          function AjaxFailed(result) {
              alert(result.status + ' ' + result.statusText);
          }  
    &lt;/script&gt;  
      &lt;link href="Styles/Site.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form method="post" action="BuyingSuccess.aspx?id=19" id="form1"&gt;
  &lt;div class="aspNetHidden"&gt;
  &lt;input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /&gt;
  &lt;input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /&gt;
  &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE1MjQ5ODA0NjlkGAIFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBSljdGwwMCRIZWFkTG9naW5WaWV3JEhlYWRMb2dpblN0YXR1cyRjdGwwMQUpY3RsMDAkSGVhZExvZ2luVmlldyRIZWFkTG9naW5TdGF0dXMkY3RsMDMFE2N0bDAwJEhlYWRMb2dpblZpZXcPD2QCA2THchHerzY1rr1yLcH18X4YPCuH2pX6++6OU9oOftLDQg==" /&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  var theForm = document.forms['form1'];
  if (!theForm) {
      theForm = document.form1;
  }
  function __doPostBack(eventTarget, eventArgument) {
      if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
          theForm.__EVENTTARGET.value = eventTarget;
          theForm.__EVENTARGUMENT.value = eventArgument;
          theForm.submit();
      }
  }
  //]]&gt;
  &lt;/script&gt;
  
  
  
  &lt;script src="/Shop3/WebResource.axd?d=gJqNbXOsVujM8wR8-hfUcLtWhOiTVJCVfh9Lo7jgFFHsWxINU3DVAgCd3VVMHS94GhZGb8YTI_r4HUkshGHWuB2iNiNOHXsKESFMdk577mE1&amp;amp;t=634669639690714017" type="text/javascript"&gt;&lt;/script&gt;
  &lt;div class="aspNetHidden"&gt;
  
      &lt;input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgL4/Z3vDgLC0ZzyCk29Agd/VrCau7HXz2AM6rx2j8z5dvoBoXKKKc+infsA" /&gt;
  &lt;/div&gt;
      &lt;div class="page"&gt;
          &lt;div class="header"&gt;
              &lt;div class="title"&gt;
                  &lt;h1&gt;
                      РРЅСЃС‚СЂСѓРєС†РёРё
                  &lt;/h1&gt;
              &lt;/div&gt;
              &lt;div class="loginDisplay"&gt;
  
                                  &lt;span class="bold"&gt;
                                  &lt;span id="HeadLoginView_HeadLoginName"&gt;usert&lt;/span&gt;
                                  &lt;/span&gt;
                                  &lt;a id="HeadLoginView_HeadLoginStatus" href="javascript:__doPostBack(&amp;#39;ctl00$HeadLoginView$HeadLoginStatus$ctl00&amp;#39;,&amp;#39;&amp;#39;)"&gt;Р’С‹Р№С‚Рё&lt;/a&gt;
  
              &lt;/div&gt;
              &lt;div class="clear hideSkiplink"&gt;
                  &lt;a href="#NavigationMenu_SkipLink"&gt;&lt;img alt="Skip Navigation Links" src="/Shop3/WebResource.axd?d=qlxWJrbukMv20w9xY1h0SQe9L8dtSGVTDQ606-0jsJTHpyJh9XQcnnSaKyQTCktjR9G7_qlWhTXAgZB4Ay9LLv-RUiwbYud3LVU-Sm9I6hQ1&amp;amp;t=634669639690714017" width="0" height="0" style="border-width:0px;" /&gt;&lt;/a&gt;&lt;div class="menu" id="NavigationMenu"&gt;
      &lt;ul class="level1"&gt;
          &lt;li&gt;&lt;a class="level1" href="Default.aspx"&gt;РРЅСЃС‚СЂСѓРєС†РёРё&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="level1" href="About.aspx"&gt;Рћ РїСЂРѕРµРєС‚Рµ&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;&lt;a id="NavigationMenu_SkipLink"&gt;&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="main"&gt;
  
      &lt;span id="MainContent_Label1"&gt;Р’С‹ РєСѓРїРёР»Рё РёРЅСЃС‚СЂСѓРєС†РёСЋ, РїРѕР·РґСЂР°РІР»СЏРµРј!&lt;/span&gt;
  
          &lt;/div&gt;
          &lt;div class="clear"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="footer"&gt;
  
      &lt;/div&gt;
  
  &lt;script type='text/javascript'&gt;new Sys.WebForms.Menu({ element: 'NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });&lt;/script&gt;&lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How to fix this issue?</p>