Proxy-Authorization: Basic header fails for HTTPS
var credentialStringValue = user + ":" + pass;
var credentialByteArray = ASCIIEncoding.ASCII.GetBytes(credentialStringValue);
var credentialBase64String = Convert.ToBase64String(credentialByteArray);
string authObject = strin开发者_如何学运维g.Format("Proxy-Authorization: Basic {0}{1}", credentialBase64String, Environment.NewLine);
System.Windows.Forms.WebBrowser _WebBrowser = new System.Windows.Forms.WebBrowser();
_WebBrowser.Navigate("http://www.google.com", string.Empty, null, authObject);
The code above is used to pass proxy credentials through to the .NET WebBrowser control. It works like a charm when going to normal HTTP URLs but when connecting to SSL it fails. What is the reason and is there a better alternative to this where SSL works?
This probably isn't what you are looking for, but have you considered using HttpWebRequest
to do this task? HttpWebRequest
can employ a WebProxy
that supports using NetworkCredentials
so you don't have to mess around with headers.
If you need WebBrowser
control to display the page, perhaps just use it for that. Use HttpWebRequest
to do the actual transfers and render the content in WebBrowser
.
For Reference: HttpWebRequest & WebProxy
精彩评论