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
  • 10,884
  • 14
  • 43
  • 67
BreakPhreak
  • 9,960
  • 25
  • 69
  • 107
  • 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.

Tim Cooper
  • 151,519
  • 37
  • 317
  • 271