Hey, I wanted to ask if anyone here has experience with RestSharp and can help me fix this issue, for longer now i have noticed that my C# script is ignoring the proxy im giving to it I made sure that its the correct proxy and correct protocol, yet somehow my function returns my real IP address and not the given proxy
public string currentProxy(string _proxy, int port) { try { RestClient client = new RestClient(); if (_proxy != null) { client.Options.Proxy = new WebProxy("socks5://" + proxy, port); } Console.WriteLine(proxy); var response = client.ExecuteGet(request: new RestRequest("https://ifconfig.me")); if ((int)response.StatusCode != 200) { Console.WriteLine((int)response.StatusCode); return null; } return response.Content.Replace("\n", ""); } catch { return null; } }
public string currentProxy(string _proxy, int port) { try { RestClient client = new RestClient(); if (_proxy != null) { client.Options.Proxy = new WebProxy("socks5://" + proxy, port); } Console.WriteLine(proxy); var response = client.ExecuteGet(request: new RestRequest("https://ifconfig.me")); if ((int)response.StatusCode != 200) { Console.WriteLine((int)response.StatusCode); return null; } return response.Content.Replace("\n", ""); } catch { return null; } }
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
C
C#
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.