Setting a temporary proxy

Let’s say you have 1 particular request that you want to pass through a given proxy (e.g. Tor running on your system and acting as a SOCKS5 proxy on port 9050).

Add this to the using statements (above the LoliCode)


And then use this snippet

// We save the old proxy so we can set it back later
var oldProxy = data.Proxy;
var oldUseProxy = data.UseProxy;

// We assign the Tor proxy and make sure proxies are ON
data.Proxy = new Proxy("", 9050, ProxyType.Socks5);
data.UseProxy = true;

// Now everything you put will be through that proxy
// e.g. request to a .onion site

// Finally put back the original proxy
data.Proxy = oldProxy;
data.UseProxy = oldUseProxy;

If your proxy requires authentication you can use this constructor instead

data.Proxy = new Proxy("", 9050, ProxyType.Socks5, "username", "password");