i have created a application in c# i want to add proxy server how can i do it.
-
You want to write a proxy server? Direct a request via a proxy server?David M– David M2010-01-12 13:18:33 +00:00Commented Jan 12, 2010 at 13:18
-
Please define "proxy server".Otávio Décio– Otávio Décio2010-01-12 13:18:47 +00:00Commented Jan 12, 2010 at 13:18
-
5I want someone else to do my work for me, how can I do it?Lazarus– Lazarus2010-01-12 13:18:53 +00:00Commented Jan 12, 2010 at 13:18
Add a comment
|
2 Answers
You can set a global proxy that way
System.Net.Uri proxyURI = new System.Net.Uri("http://64.202.165.130:3128");
System.Net.GlobalProxySelection.Select = new System.Net.WebProxy(proxyURI);
Or set it for a WebRequest like this:
var proxyURI = new System.Net.Uri("http://64.202.165.130:3128");
var proxy = new System.Net.WebProxy(proxyURI);
// If u need passwords:
proxy.Credentials=new NetworkCredential(username,password);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.stackoverflow.com");
request.Proxy = proxy;
}