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:

using System;
using System.Net;
using System.Net.Http;

var http = new HttpClient(new HttpClientHandler
    Proxy = new WebProxy("socks5://")

Console.WriteLine(await http.GetStringAsync("https://bbcnewsv2vjtpsuy.onion"));

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 updated