Why doesn't WebProxy BypassProxyOnLocal work for me?

I am trying to get the HTTP calls I make with C # .NET to a local address (localhost: 3000) in order to use the proxy server that I installed (so that I can go through the violinist). Using the WebProxy subproject works if I point the destination URL to a non-local address, however I need to point it to the local web server that I have (on localhost: 3000), and when I do this, the request is not collected through the proxy.

I have included "proxyObject.BypassProxyOnLocal = false". This should make it work no? Any suggestions on how to get a request to go through WebProxy for http calls destined for a local address?

    WebProxy proxyObject = new WebProxy("http://localhost:8888/", false);
    proxyObject.Credentials = new NetworkCredential(); 
    proxyObject.BypassProxyOnLocal = false;
    WebRequest.DefaultWebProxy = proxyObject;

    var request = (HttpWebRequest)WebRequest.Create(targetUri);

    // I also included this line as a double check
    request.Proxy = proxyObject;

Subsequent calls do not go through the proxy, for example, when I do:

 var res = (HttpWebResponse)req.GetResponse();

thank

+3

Source: https://habr.com/ru/post/1728113/


All Articles