我正在使用HttpWebRequest向使用自定义身份验证的WCF服务发送请求,使用以下代码:
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
SetBasicAuthHeader(request, "User1", "Pwd1");
request.ClientCertificates.Add(cert);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
我收到400错误。
我使用Fiddler检查了请求和响应标头,这里是发送的请求标头:
GET /ProjName/TestService.svc/GetDetails/ABC123 HTTP/1.1
Cookies/Login
Authorization: Basic xxxxxxxxxxxxxxxxxxxxx
Transport
Connection: Keep-Alive
Host: ServerName
我将此作为回复:
HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Thu, 04 Aug 2016 14:21:29 GMT
Content-Length: 0
有谁能告诉我缺少什么,我在这里做错了什么?