Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do WCF REST services support HTTP 301 redirects?

Is it possible to implement a HTTP 301 redirect for a WCF REST Service so that URLs of the form:

http://server/customers/?name=John

redirects to

http://server/customers/324

(For the client-side case of this question, see Does the WCF REST WebChannelFactory client support REST services that use redirects?)

like image 464
Jacob Avatar asked Feb 28 '23 14:02

Jacob


1 Answers

Sure just set the location and the status code

WebOperationContext.Current.OutgoingResponse.Location = "http://server/customers/324";
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.MovedPermanently;

I don't know how the WCF client handles redirects, but it is relatively simple to do using HttpWebRequest.

like image 196
Darrel Miller Avatar answered Mar 12 '23 07:03

Darrel Miller