Click here to Skip to main content
16,020,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am developing an application that accesses webpage via a proxy server, i am using the following code-
C#
HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create("http://www.ncedc.org/cgi-bin/catalog-search2.pl");

            // Obtain the 'Proxy' of the  Default browser.  
            IWebProxy proxy = myWebRequest.Proxy;
            // Print the Proxy Url to the console.
            if (proxy != null)
            {
                Console.WriteLine("Proxy: {0}", proxy.GetProxy(myWebRequest.RequestUri));
            }
            else
            {
                Console.WriteLine("Proxy is null; no proxy will be used");
            }
            WebClient client = new System.Net.WebClient();
            NameValueCollection postData = new NameValueCollection();
            postData.Add("format", "ncread");
            postData.Add("mintime", "2013/08/03,00:00:00");
            postData.Add("minmag", "1.0");
            postData.Add("etype", "E");
            postData.Add("outputloc", "web");
            postData.Add("searchlimit", "200000");
            client.Proxy = new WebProxy("10.10.10.1",8080);
            byte[] data = client.UploadValues("http://www.ncedc.org/cgi-bin/catalog-search2.pl", "POST", postData);
            string html = System.Text.Encoding.UTF8.GetString(data);
            if (File.Exists("C:\\Windows\\Temp\\text.html"))
            {
                File.Delete("C:\\Windows\\Temp\\text.html");
            }
            File.WriteAllText("C:\\Windows\\Temp\\text.html", html);
            Console.ReadKey();

        }


throws authentication error-407 please help
Posted
Updated 6-Aug-13 23:48pm
v2

1 solution

Try with the default credentials as shown.

client.Proxy.Credentials = CredentialCache.DefaultCredentials;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900