1

I am making a web request using a proxy

HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(inputURL);
WebProxy proxy = new WebProxy(101.1.1.1,80);

wr.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-US");
wr.Timeout = 100000;
wr.Method = "GET";
wr.ContentType = "text/html;charset=UTF-8";

When I look in Fiddler, I do not see any proxy information. How can I make sure proxy is being used correctly?

Thanks

1 Answer 1

2
string proxyIP = "61.135.178.114";
int proxyPort = 80;

var req = (HttpWebRequest)HttpWebRequest.Create("http://ip-api.com/json");
req.Proxy = new WebProxy(proxyIP, proxyPort);
var resp =   req.GetResponse();
var json = new StreamReader(resp.GetResponseStream()).ReadToEnd();

var myip = (string)JObject.Parse(json)["query"];

if (myip == proxyIP)
{
    MessageBox.Show("OK...");
}

You will need Json.Net library to run this code

Sign up to request clarification or add additional context in comments.

2 Comments

var myip = (string)JObject.Parse(json)["query"]; what is query?
Because that API returns the caller's ip address in that field. Just print the json to see what it returns..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.