🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / proxy eklemek

1-) C# RMOS - proxy eklemek

 

kaynak : https://stackoverflow.com/questions/29856543/httpclient-and-using-proxy-constantly-getting-407

 

public CimriApi()

        {

            ServicePointManager.Expect100Continue = true;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            CookieContainer cookies = new CookieContainer();

            HttpClientHandler handler = new HttpClientHandler();

            handler.CookieContainer = cookies;

 

            string proxyHost = "222.254.239.53", proxyPort="80", proxyUserName= "asd@gmail.com", proxyPassword= "aaa";

            var proxy = new WebProxy

            {

                Address = new Uri($"http://{proxyHost}:{proxyPort}"),

                BypassProxyOnLocal = false,

                UseDefaultCredentials = true,

 

                // *** These creds are given to the proxy server, not the web server ***

                Credentials = new NetworkCredential(

        userName: proxyUserName,

        password: proxyPassword)

            };

 

            var httpClientHandler = new HttpClientHandler

            {

                Proxy = proxy,

        //UseCookies = true,

              //CookieContainer = cookies,

              //UseDefaultCredentials=true,

            };

 

          

             client = new HttpClient(handler: httpClientHandler, disposeHandler: true);

 

            client.DefaultRequestHeaders.Add("User-Agent", "PostmanRuntime/7.29.2");

        }

 2023 Mart 16 Perşembe
 376