【问题标题】:Do WCF REST services support HTTP 301 redirects?WCF REST 服务是否支持 HTTP 301 重定向?
【发布时间】:2010-11-05 04:46:27
【问题描述】:

是否可以为 WCF REST 服务实现 HTTP 301 重定向,以便以下形式的 URL:

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

重定向到

http://server/customers/324

(本题的客户端案例见Does the WCF REST WebChannelFactory client support REST services that use redirects?

【问题讨论】:

    标签: wcf rest http-status-code-301


    【解决方案1】:

    当然只要设置位置和状态码

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

    我不知道 WCF 客户端如何处理重定向,但使用 HttpWebRequest 相对简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 2015-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多