Want to use Tor so that you can make annoymous and secure web requests while coding in C#? Use this easy technique. Typically when making an HttpWebRequest with C# you would write something to this effect:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yourtargetURL.org");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
This will work fine, however your connection will not be anonymous. Using Tor, you can effectively create an anonymous connection. First, make sure to install Tor and run it. The typical Tor Windows install will install Privoxy along with Vidalia. To make your C# web request run through Tor, you need to override the default proxy property to contact Prioxy.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yourtargetURL.org");
request.Proxy = new WebProxy("127.0.0.1:8118"); // default privoxy port for tor
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
127.0.0.1:8118 is the default address for Privoxy. Your HttpWebRequest will now be routed through Tor. Make sure that you do not have any firewalls blocking this default port.



2 Comments
Super!!!!!!!! Thanks
Or, if Privoxy won’t/can’t be installed for some reason, then this would work for basic requests too…
public class TorRequest
{
public static WebRequest Create(Uri requestUri)
{
return WebRequest.Create(“https://tor-proxy.net/proxy/tor/browse.php?u=” + HttpUtility.UrlEncode(requestUri.ToString()));
}
}