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());
            HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
            response.Cookies = webReq.CookieContainer.GetCookies(webReq.RequestUri);

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

6 Years
Discussion Span
Last Post by khan17

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();


WebException was handled
The remote server returned an error: (407) Proxy Authentication Required.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.