D
D
deadbyte2020-11-02 22:21:57
C++ / C#
deadbyte, 2020-11-02 22:21:57

C#. Your proxy server with authorization. Are there simple solutions?

Hello. I need to add an http proxy like "localhost:port" to my application. The proxy should simply redirect all requests to an external proxy with authorization like "user:[email protected]:port" and send the received response to the browser. That is, in fact, you need a proxy authorizer. Is there any easier way to add this functionality to my solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-11-03
@firedragon

WebProxy proxy = new WebProxy();
proxy.Address = new Uri("mywebproxyserver.com");
proxy.Credentials = new NetworkCredential("usernameHere", "pa****rdHere");  //These can be replaced by user input
proxy.UseDefaultCredentials = false;
proxy.BypassProxyOnLocal = false;  //still use the proxy for local addresses

WebClient client = new WebClient();
client.Proxy = proxy;

string doc = client.DownloadString("http://www.google.com/");

B
basrach, 2020-11-08
@basrach

Why do you need C# here?
It will be enough to take nginx and specify "user:[email protected]:port" as the upstream.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question