A
A
Ai Lab2015-01-18 06:42:53
C++ / C#
Ai Lab, 2015-01-18 06:42:53

Why does C# ignore proxy settings through HttpWebRequest?

The bottom line is in the code below, judging by Google, it is correct and the request should be called using the specified proxy server, but the application flatly refuses to use the proxy and just downloads directly. If anyone has come across this, what is wrong with this code?

<code lang="cs">
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
WebProxy proxyObject = new WebProxy("127.0.0.1:8080");
req.Proxy = proxyObject;
</code>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IPv4, 2015-01-18
@IPv4

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
WebProxy proxyObject = new WebProxy("127.0.0.1", 8080);
req.Proxy = proxyObject;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question