I am working on WPF application and need to test some server requests with a proxy. I can't find anyone for free with username and password. Does anyone have an idea or can give me a guide?
1 Answer
Use this code . this code helps you to enter username or password to credentials if the Http Proxy needs it :
string PROXY = "199.21.97.75:80"; //TYPE OF PROXY : HTTP
string WEBSITE = "http://www.google.com";
string USERNAME = "";
string PASSOWRD = "";
bool CREDENTIALS; //if Proxy needs it
HttpWebRequest HTTP = (HttpWebRequest)HttpWebRequest.Create(WEBSITE);
HTTP.Proxy = new WebProxy(PROXY);
if (CREDENTIALS == true)
{
HTTP.Proxy.Credentials = new NetworkCredential(USERNAME, PASSOWRD);
}
else
{
HTTP.Proxy.Credentials = CredentialCache.DefaultCredentials;
}