title: How to return error pages with body using HttpListener/HttpListenerResponse
body: <p>I'm in the process of creating a REST API using HttpListener in .NET (C#). This all works out great, except for one slight issue.</p>
  
  <p>I'm trying to return responses with Status Codes other than OK (200), for instance ResourceNotFound (404).</p>
  
  <p>When I set the StatusCode of the HttpListenerResponse to something other than 200, and create a response body (using HttpListenerResponse.OutputStream), it seems to be resetting the status code to 200. I'm not able to send a response with StatusCode 404 and a message body. However, this should be possible according to the HTTP specs. I'm checking the requests and responses with Fiddler, but I'm not able to get what I'm looking for.</p>