我正在从VB应用程序访问REST Web服务.我创建一个HttpWebResponse对象并在其上调用GetRequestStream就好了,但是当我调用GetResponse时,我得到一个401异常. 这是我的代码(修改后发布): Dim webRequest
这是我的代码(修改后发布):
Dim webRequest = DirectCast(WebRequest.Create(endpoint), HttpWebRequest) webRequest.Method = "POST" webRequest.ContentLength = contentLength webRequest.ContentType = "application/x-www-form-urlencoded" request.Credentials = New NetworkCredential(Username, Password) ' Works fine Using stream As Stream = webRequest.GetRequestStream() stream.Write(data, 0, data.Length) End Using ' Barfs Dim response As HttpWebResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse)
一旦我调用“webRequest.GetResponse()”,我就会收到401异常.响应中有一个“WWW-Authenticate”标头,带有适当的域.我已经尝试设置“webRequest.PreAuthenticate = True”,以及使用“webRequest.Headers.Add(HttpRequestHeader.Authorization,_authheader)”手动设置标题.
我似乎无法使用Fiddler / Wireshark等监视这些请求,因为这是SSL流量,我确信有一种方法可以监控它,我还没有找到它.
提前致谢,
–Connor
Decrypting HTTPS-protected traffic with Fiddler