Click here to Skip to main content
11,922,320 members (39,893 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# .NET Network proxy

I'm trying to build an application that checks the availiability of some internet addresses. Therefor, i'm doing a webrequest. I need to use a proxy server on which the user, under which the application is running, isnt allowed. Thus i'm setting the proxy credentials. Unfortunately I always get a "407 proxy authentication required" error. When I run the application under an user that is allowed on the proxy, it works finde. It seems that the credentials wouldnt work but i have no idea what else to do?
Hopefully someone can help me with the problem!

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("address");  
var proxy = new WebProxy("proxy", 8080);
proxy.Credentials = new System.Net.NetworkCredential("user", "password", "doamin");
request.Proxy = proxy;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50215)";
request.Method = "GET";
request.ContentType = "text/html";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

kind regards and thanks in advance!
Posted 16-Feb-12 2:26am
Bernhard Hiller 17-Feb-12 3:54am
Some hints, not sure whether that's the solution:
- var proxy = new WebProxy("http://proxy", 8080);
- did you check for typos in the credentials?
KapilWaghe 5-Apr-12 15:44pm
Hey did you got the solution for the problem. Please let me know I am having the same problem.
lucius234 5-Apr-12 16:32pm
unfortunately no. No idea how to solve... We are using a proxy without authentication now. Not really a solution. Let me know if you find something - would be very thankful! This problame made me crazy.;)
Cross my fingers for you!
KapilWaghe 6-Apr-12 12:29pm

Thanks for the reply. Really its a hair pulling issue.
I am trying continuously since last 4 days.
Definitely I will come to you as I got the solution. Well in you answer you told that :We are using a proxy without authentication now. Not really a solution.
It means that you are using free proxies not paid/private proxies?

Please let me know if you got something.

Awaiting your response.

KapilWaghe 7-Apr-12 9:30am
Hey I got something...
I contacted to the proxy provider and said that :
"some locations in India have difficulties connecting to our servers in PA." so they gave me new proxies and they are working great. It means that it is an issue of the proxy server and the current location we are in.



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

  Print Answers RSS
0 OriginalGriff 493
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 243
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,231
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,356
3 George Jonsson 2,865
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web04 | 2.8.151120.1 | Last Updated 16 Feb 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100