title: issue with Response.OutputStream.Write
body: <p>I have a problem with this method, for some reason, I send request to my asp page, then read the <code>Response</code> stream and I get the content of my asp page along with the data I wrote into <code>Response.OutputStream.Write(info, 0, info.Length)</code>.</p>
  
  <p>In my case, I write the string "1" as bytes, and the output on the client program is:</p>
  
  <pre><code>1&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;&lt;title&gt;
  
  &lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
      &lt;form method="post" action="LauncherLogin.aspx" id="form1"&gt;
  &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZMraZTexYtyyQ9NaNN0YMvYIep5peaSEIrDBqxTff6rW" /&gt;
  
      &lt;div&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I don't want this HTML in the response I receive, how do I get rid of it?</p>
  
  <p>Client Code (c# program):</p>
  
  <pre><code>public static string SendInformation(string values)
  {
      ASCIIEncoding encoding = new ASCIIEncoding();
  
      string postData = values;
      byte[] data = encoding.GetBytes(postData);
  
      // Prepare web request...
      HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serverAddress + commmunicationForm);
      myRequest.Method = "POST";
      myRequest.ContentType = "text/html";
      myRequest.ContentLength = data.Length;
      string result;
  
      using (Stream stream = myRequest.GetRequestStream())
      {
          stream.Write(data, 0, data.Length);
      }
      using (WebResponse response = myRequest.GetResponse())
      {
          using (var reader = new StreamReader(response.GetResponseStream()))
          {
              result = reader.ReadToEnd();
              return result;
          }
      }
  }
  </code></pre>
  
  <p>ASP.aspx.cs Code (Server Side):</p>
  
  <pre><code>if (dt.Rows.Count &gt; 0)
  {
      Response.Clear();
      Response.ClearContent();
      Response.ClearHeaders();
      Response.Buffer = false;
      string errNum = dt.Rows[0][0].ToString();
      byte[] info = Encoding.ASCII.GetBytes(errNum);
      Response.OutputStream.Write(info, 0, info.Length);
      Response.Flush();
  }
  </code></pre>
  
  <p>Even if I do just this:</p>
  
  <pre><code>string errNum = dt.Rows[0][0].ToString();
  byte[] info = Encoding.ASCII.GetBytes(errNum);
  Response.OutputStream.Write(info, 0, info.Length);
  Response.Flush();
  </code></pre>
  
  <p>I still get the html code :|</p>
  
  <p>I did try <code>Response.Clear()</code> and other <code>.Clear()</code> methods with no success.</p>