Accessing Tor .onion URLs via HttpClient with .NET6
In .NET6, there is built-in support for SOCKS4/5 proxies! This means you can install the Tor service and without anything else, access any .onion URL with plain HttpClient:
1
using System;
2
using System.Net;
3
using System.Net.Http;
4
5
var http = new HttpClient(new HttpClientHandler
6
{
7
Proxy = new WebProxy("socks5://127.0.0.1:1338")
8
});
9
10
Console.WriteLine(await http.GetStringAsync("https://bbcnewsv2vjtpsuy.onion"));
Copied!
NOTE: I could not get this to work with gRPC, which requires HTTP/2.
You can get the daily .NET6 SDK installer permalinks from:
Last modified 1mo ago
Copy link