WCF REST services support HTTP 301 redirects?

Is it possible to implement HTTP 301 redirection for WCF REST service to form URLs:

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

redirected to

http: // server / customers / 324

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

+4
source share
1 answer

Of course, just set the location and status code

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

I do not know how the WCF client handles redirects, but it is relatively simple to do this using HttpWebRequest.

+8
source

Source: https://habr.com/ru/post/1286626/


All Articles