0

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.

ole
  • 159
  • 2
  • 13
  • I'll say it even tho i guess you did, but you DID double, triple, and super-duper-quadruple check that your credentials are good right ? – Mathieu VIALES Oct 26 '17 at 15:23
  • Yes of course, but thanks for the suggestion. – ole Oct 26 '17 at 15:25
  • This totally didn't happen to me. Nope. Never spent two days with a god damn space at the end of my password messing it all up :-/ – Mathieu VIALES Oct 26 '17 at 15:29
  • I looked at your code but i couldn't see anything obviously wrong ... i'm not a master at HttpClients, sorry :-( – Mathieu VIALES Oct 26 '17 at 15:29
  • Have you tried setting "PreAuthenticate = true" in your webproxy? You have it at the handler level, but not in the webproxy as I've seen in some other postings. – Todd Oct 26 '17 at 16:27
  • I've tried every possible combination of parameters in both webproxy and handler at this point :/ Also, webproxy doesn't have preauthenticate? – ole Oct 26 '17 at 16:31

0 Answers0