Search code examples
.net-corehttpclientrestsharp

How do not use proxy with RestSharp in .NET Core 3


I need to use RestSharp post without any default/system proxy. I did that with HttpClient with that :

var handler = new HttpClientHandler { UseProxy = false };
var client = new HttpClient(handler);

How can I do something like that (UseProxy) with RestSharp?

Thanks


Solution

  • you could try something like this. note - WebProxy method is from System.Net.WebProxy

    var proxy = new WebProxy("non_Existing_Server", 8888) {BypassProxyOnLocal = false};
    var Client = new RestClient("http://www.google.com");
    Client.Proxy = proxy;