0

The code I'm using is

WebClient webClient = new WebClient();                    
string xmlResult = webClient.DownloadString("https://kat.cr/usearch/ubuntu/?rss=1");

I'm a bit confused as the URL seems to tunnel through to a secondary page kastatic.com:443 and then kat.cr:443 (if I'm understanding Fiddler correctly).

The server certificate seems to be fine so adding the following code does nothing helpful

 ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
                    {
                        return true;
                    };

I've also tried setting the useragent headers on the webClient object in case I need to identify as a browser or something but I don't think I'm on the right track.

Edit: The response I get is "12a9" with 2 odd ascii characters trailing it (a question mark symbol and a white circle with black border.

Amit Kumar Ghosh
  • 3,618
  • 1
  • 20
  • 24
kovorka
  • 38
  • 5
  • 2
    What's the problem? What error did you get, if any? – Evan Mulawski Jul 14 '15 at 16:00
  • [Whats this](http://stackoverflow.com/questions/20064505/requesting-html-over-https-with-c-sharp-webclient)? I remember having to do something like this a long time back. Defo something to do with SSL so could be worth a shot – musefan Jul 14 '15 at 16:01
  • it's returning plain `XML`. whats wrong? – Amit Kumar Ghosh Jul 14 '15 at 16:07
  • Hi musefan, I saw that post and that didn't really apply. The site seems to be using TLS/1.2 – kovorka Jul 14 '15 at 16:09
  • Hi Amit, if you view the URL in a browser, you get the XML. If you put the URL into webClient.DownloadString, you get a symbol character (which I assume refers to a redirect or tunnel). – kovorka Jul 14 '15 at 16:11

1 Answers1

2

If you look at the headers in Fiddler, the response is GZip-encoded (compressed). See this answer for how to deal with this, since there's no "quick and easy" way with the WebClient class.

Community
  • 1
  • 1
Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144