How to return 404 not found from wcf service?

As soon as I get full control over the header / body of HTTP messages, I use the Message class. For example, to return some XML, 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? many thanks

+3
source share
1 answer

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

+5
source

Source: https://habr.com/ru/post/1769371/