I'm totally aware that this issue(or similar) has been posted thousands of times. Yet, none of the solutions works for me. I've made proxy connections in c# hundreds of times, but for some reason I keep getting 407 now. I'm simply trying to make a get request to google, using a very basic http proxy.
After some time I ended up looking at the answer to the question posed here: HttpClient and using proxy - constantly getting 407
Which for some reason still returns me a 407. Here's my exact code
string proxyUri = string.Format("{0}:{1}", "xxx.xxx.xxx.xxx", "xxx");
NetworkCredential proxyCreds = new NetworkCredential(
"xxxx",
"xxxx"
);
WebProxy proxy = new WebProxy(proxyUri, false)
{
UseDefaultCredentials = false,
Credentials = proxyCreds,
};
var cookieContainer = new CookieContainer();
var handler = new HttpClientHandler()
{
Proxy = proxy,
PreAuthenticate = true,
UseDefaultCredentials = false,
CookieContainer = cookieContainer
};
var client = new HttpClient(handler)
var result = client.GetAsync("https://www.google.com");
I feel like everything looks correct, but for some reason the result isn't. Any advice would be greatly appreciated.
EDIT: I've now even tried with webclient, which has the exact same issue. I'm thinking that it might be using the proxy as a http proxy and not https? Could the protocol somehow be specified?
EDIT 2: When using webclient I've noticed that I get "operation timeout", when using correct credentials and 407 immediately, when credentials are wrong.