WebOperationContext.Current.OutgoingResponse.StatusDescription is ignored

1.3k views Asked by At

Value that I set on server side for WebOperationContext.Current.OutgoingResponse.StatusDescription property is ignored. Client side gets a default message, for example Not Found for 404 code, OK for 200.

1

There are 1 answers

1
Despertar On

I also had this same problem. I can return the body of the response but everything else, status code, headers, etc. is overridden somewhere down the line.

To get around this you can throw a WebFaultException which lets you set the status code.

throw new WebFaultException<string>("Tell the calling client what went wrong",  System.Net.HttpStatusCode.Conflict);