Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebOperationContext.Current.OutgoingResponse.StatusDescription is ignored

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.

like image 576
brain_pusher Avatar asked Mar 01 '26 07:03

brain_pusher


1 Answers

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);
like image 146
Despertar Avatar answered Mar 03 '26 20:03

Despertar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!