0

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();
1
  • I've used fiddler to analyze the request headers and it would appear that the proxy authorization header is missing...... Commented Oct 4, 2013 at 9:58

1 Answer 1

0

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.......

Sign up to request clarification or add additional context in comments.

2 Comments

Just to be clear, did it work when you changed 'kerberos' to 'ntlm', or did you also have to upgrade to .Net 4?
I needed to set the auth type to "ntlm" due to the network setup but there is a problem with earlier versions of the .NET framework and the upgrade to version 4 of the .NET framework was required to fix the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.