hello all,
i just searched via google and found a set of codes to login to a web site using httpwebrequest. but whenever i tried using the codes i got the very same exception that

The remote server returned an error: (407) Proxy Authentication Required.

one of the sample code i ve used

ArrayList theQueryData = new ArrayList();
   
            theQueryData.Add(String.Format("{0}={1}", "username", HttpUtility.UrlEncode("test")));
            theQueryData.Add(String.Format("{0}={1}", "password", HttpUtility.UrlEncode("test")));
            string Parameters = String.Join("&", (String[])theQueryData.ToArray(typeof(string)));
            Uri url = new Uri("https://www.test.com/test/testlogin.cfm");
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(url);
        
            webReq.ContentType = "application/x-www-form-urlencoded";
            webReq.Method = "POST";
            webReq.AllowWriteStreamBuffering = true;
            webReq.AllowAutoRedirect = false;
            webReq.Credentials = CredentialCache.DefaultCredentials;
            webReq.CookieContainer = container;
            webReq.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
            webReq.KeepAlive = true;
            // We write the parameters into the request 
            StreamWriter sw = new StreamWriter(webReq.GetRequestStream());
            sw.Write(Parameters);
            sw.Close();
            HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
            response.Cookies = webReq.CookieContainer.GetCookies(webReq.RequestUri);

what should i do to get it work..
need help.

no hope at all till now,

when i tried to download a file from a web page also im getting the same exception. i dont know why its happened. any body pls help. i used the code sample

private void button1_Click(object sender, EventArgs e)
        {
            WebClient wc = new WebClient();

            wc.DownloadFile(textBox1.Text,textBox2.Text);


        }
WebException was handled
The remote server returned an error: (407) Proxy Authentication Required.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.