Click here to Skip to main content
11,802,205 members (54,249 online)
Rate this: bad
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 1:26am
Bernhard Hiller at 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 at 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 at 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 at 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 at 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 475
1 KrunalRohit 341
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CHill60 195
0 OriginalGriff 2,715
1 Maciej Los 1,900
2 KrunalRohit 1,797
3 CPallini 1,550
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web01 | 2.8.151002.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