I'm trying to get and set cookies using the Tor API. The problem is that the SocksPortHandler doesn't have CookieContainer nor InnerHandler.

I tried using Knapcode.SocketToMe.Http.CookieHandler and set its InnerHandler to SocksPortHandler, but with no success. here is the code -

  using (CookieHandler cookieHandler = new CookieHandler())
                SocksPortHandler socksPortHandler = new SocksPortHandler("", socksPort: 9050);
                cookieHandler.InnerHandler = socksPortHandler;
                using (HttpClient httpClient = new HttpClient(cookieHandler))
                   .....setting httpClient properties.....
                    HttpResponseMessage message = httpClient.GetAsync(uri).Result;
                    response = message.Content.ReadAsStringAsync().Result;
                    cookieHeader = cookieHandler.CookieContainer.GetCookieHeader(uri);

how can I do it? Thanks

1 Answer 1


just found the answer https://github.com/nopara73/DotNetTor/issues/18 hope it will help others

  • Could you describe with a few more words what helped you? Thanks.
    – Jens Kubieziel
    Apr 28, 2020 at 21:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .