3

Once, to have a complete control over the head/body of HTTP messages - I use the Message class. To return some XML, for example, I call

  public Message ShowRunResults()
  {
    // some [OperationContract] implementation
    webContext.CreateTextResponse(result.ToString(), "application/xml", Encoding.ASCII);
  }

The question is how to return 404 not found or other HTTP codes? thanks a lot

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
BreakPhreak
  • 10,940
  • 26
  • 72
  • 108
  • possible duplicate of [How can I return a custom HTTP status code from a WCF REST method?](http://stackoverflow.com/questions/140104/how-can-i-return-a-custom-http-status-code-from-a-wcf-rest-method) – Randy Levy Oct 13 '10 at 15:43

1 Answers1

5

Using WebOperationContext.Current.OutgoingResponse, you can set the HTTP code and status.