title: .Net Core returning an int in HttpResponseMessage
body: <p>I'm trying to replicate the following ASP.Net code in .Net Core:</p>
  
  <pre><code>return Request.CreateResponse( HttpStatusCode.OK, 100 );
  </code></pre>
  
  <p>I have tried:</p>
  
  <pre><code>using (MemoryStream ms = new MemoryStream())
  {
      using (StreamWriter sw = new StreamWriter(ms))
      {
          sw.Write(100);
          return new HttpResponseMessage(HttpStatusCode.OK) {Content = new StreamContent(sw.BaseStream)};
      }
  }
  </code></pre>
  
  <p>but it is not giving me the result I would like. I'm working with a legacy API which must read an integer from the response stream so I don't have the option of changing the design.</p>
  
  <p>Below is the code which receives the response, the TryParse always fails, I need it to succeed. Unfortunately I have no way of debugging it:</p>
  
  <pre><code>using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  {
      string result = reader.ReadToEnd();
  
      int value = 0;
  
      if (Int32.TryParse(result, out value))
      {
          return value;
      }
  }
  </code></pre>