Question

I am using the following code to get load xml from a webpage however I keep receiving the error "The remote server returned an error: (407) Proxy Authentication Required."

I've looked at a large number of posts on both stackoverflow and other sites and am unable to resolve the problem. I have been told by our IT support dept that this is probably down to the fact that they are forcing the proxy server to use kerberos authentication but as you can see I have specified the kerberos as the authentication type.

Here is the code I am currently using:

         IWebProxy proxy = request.Proxy;
        if (proxy != null)
        {
            string proxyuri = proxy.GetProxy(request.RequestUri).ToString();
            var cc = new CredentialCache();
            cc.Add(
                new Uri(proxyuri),
                "Kerberos", //if we don't set it to "Kerberos" we get error 407 with ---> the function requested is not supported.
                CredentialCache.DefaultNetworkCredentials);


            request.UseDefaultCredentials = true;
            request.Proxy = new WebProxy(proxyuri, false);
            request.Proxy.Credentials = cc;

        }

        //set some sort of user-agent string
        request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";

        // Create a new XmlDocument 
        var doc = new XmlDocument();

        var stream = request.GetResponse().GetResponseStream();
Était-ce utile?

La solution

turns out I needed to set the authentication type to "ntlm" rather than "kerberos" for the network in question but the main reason for the error is that there is a problem in versions 2, 3 and 3.5 of the framework. (confirmed by Microsoft) - Upgrading the project to .NET4 solved the problem.......

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top