Do WCF REST services support HTTP 301 redirects?
-
06-07-2019 - |
Question
Is it possible to implement a HTTP 301 redirect for a WCF REST Service so that URLs of the form:
redirects to
(For the client-side case of this question, see Does the WCF REST WebChannelFactory client support REST services that use redirects?)
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow