Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以为 WCF REST 服务实现 HTTP 301 重定向,以便以下形式的 URL:
http://server/customers/?name=约翰
重定向到
http://服务器/客户/324
(有关此问题的客户端案例,请参阅WCF REST WebChannelFactory 客户端是否支持使用重定向的 REST 服务?)
当然只需设置位置和状态码
WebOperationContext.Current.OutgoingResponse.Location = "http://server/customers/324"; WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.MovedPermanently;
我不知道 WCF 客户端如何处理重定向,但使用 HttpWebRequest 相对简单。