【发布时间】:2013-09-23 09:06:54
【问题描述】:
我有一个需要基本身份验证标头的网络服务。但是,当我使用
调用它时 var header = "Authorization: Basic " +
CreateBasicHttpAuthenticationHeader(login, password);
webRequest.Headers.Add(header);
var webResponse = (HttpWebResponse)webRequest.GetResponse();
它返回一个 303 - 查看其他:
POST https://myservice/rates HTTP/1.1
Authorization: Basic QXZ...NjY=
Content-Type: application/x-content
X-API-Version: 1.1
If-Unmodified-Since: Mon, 23 Sep 2013 08:32:27 GMT
User-Agent: UserAgent
回复:
HTTP/1.1 303 See Other
Date: Mon, 23 Sep 2013 08:30:57 GMT
X-Opaque-ID: q8nxxxxc
Location: https://myservice/rates
Content-Length: 0
.Net 然后自动向新位置发送 GET 请求:
GET https://myservice/rates HTTP/1.1
Content-Type: application/x-content
X-API-Version: 1.1
If-Unmodified-Since: Mon, 23 Sep 2013 08:32:27 GMT
User-Agent: UserAgent
但这次不发送授权头。您知道一种方法来告诉它在所有呼叫中发送所有标头吗?我应该告诉它不要跟随内容吗?
【问题讨论】:
标签: c# redirect http-headers httpwebrequest