title: Unable to write to HttpContext's response body in asp.net core 2.1's middleware
body: <p>Here it is our middleware's code snippet</p>
  
  <pre><code>public Task InvokeAsync(HttpContext context)
  {
      if(!found)
      {
          context.Response.StatusCode = StatusCodes.Status401Unauthorized;
          return context.Response.WriteAsync("Something wrong");
      }
      return _next(context);
  }
  </code></pre>
  
  <p>The problem is that while the client app receives error code 401 which is fine but "Something wrong" string is not found in the response's body. What are we missing here?</p>