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.
Asked
Active
Viewed 1,284 times
3
-
What is your client? I had the same when working with Android clients. – Aliostad May 05 '11 at 14:12
1 Answers
1
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);

Despertar
- 21,627
- 11
- 81
- 79
-
Unfortunately, throwing WebFaultException (or any exception) results in status 500 Internal Server Error being returned to the client, not the 400 Bad Request or 409 Conflict or other HttpStatusCode passed into WebFaultException
's constructor. – JMD Jul 10 '12 at 20:25