title: Is there any difference between Body.Write and returning of a string?
body: <p>When you return a response form an asp .net core controller you can return data in two ways (there may be more but I am just focusing on these two). My question is what is the difference between the two methods (if any); return a value vs writing directly to the body?</p>
  
  <pre><code>    [HttpGet("Fetch_Write")]
      public void Fetch_Write()
      {
          HttpContext.Response.ContentType = "application/json";
          var s = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { data = "my_fetched_data" }));
          HttpContext.Response.Body.Write(s, 0, s.Length);
      }
  </code></pre>
  
  <p>In the method above the return type of the function is void and I am writing a content directly to the response body, but the version below my function returns a string. When using postman I get the same response from both api calls, is there a difference between the two? Should I use one over the other?</p>
  
  <pre><code>    [HttpGet("Fetch_Return")]
      public string Fetch_Return() 
      {
          HttpContext.Response.ContentType = "application/json";
          return JsonConvert.SerializeObject(new { data = "my_fetched_data" });
      }
  </code></pre>
  
  <p>My guess is is that the function that returns a string does something similar later down the line where it writes the content to the body as I have done in the first code snippet function but I am not sure.</p>