WebOperationContext.Current.OutgoingResponse.StatusDescription ignored

The value that I set on the server side for the WebOperationContext.Current.OutgoingResponse.StatusDescription property is ignored. The client side receives a default message, for example Not Found for 404 code, OK for 200.

+3
source share
1 answer

I also had the same problem. I can return the response body, but everything else, status code, headers, etc. Overridden somewhere along the line.

To get around this, you can throw a WebFaultException, which allows you to set a status code.

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

All Articles