Visual Studio 2008. Windows XP, SP-2. I wrote a small program for reading the code of the html page, namely https://www.gismeteo.ru/city/legacy/4392/ . Read code:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };//обход подлинности сертификата byte[] response = null; string str = ""; using (WebClient client = new WebClient()) // WebClient class inherits IDisposable { try { response = client.DownloadData("https://www.gismeteo.ru/city/legacy/4392/"); str = System.Text.Encoding.UTF8.GetString(response); } catch (WebException ex) { Logging("Network error: " + ex.Message + " - "); } catch (Exception exception) { Logging(exception.Message + " - "); } } 

And everything seemed to be normal. But today I noticed (I run every day in the morning) that I suddenly received the code of another page. Having climbed the site, I came to the conclusion that the code was read https://beta.gismeteo.ru/weather-tula-4392/ (I found unformatted code only there, not to mention some lines). I study recently. What could have caused this to happen?

  • Perhaps some jamb on the server (for example, the redirection should have happened with a certain User-Agent or something like that, but at the same time there was an error in the condition, missing an empty User-Agent). - Surfin Bird
  • @Surfin Bird, is there an adequate way to solve this, except to check whether that page was read? - Questioner
  • in general, in my opinion, no, so the server can always give anything. Although you can try to mimic under the browser (first of all by copying the User-Agent), it may help. - Surfin Bird
  • @Surfin Bird, which is interesting, with the tests for the next 5 hours this was not observed. But I will try mimkrirovanie, thanks, somehow forgot this option, although not yet used with the WebClient, but this is a trifle. But do not tell me which client is better to use or will not play a role especially? - Questioner
  • It is unlikely to play, just not mobile UA, or else it will redirect somewhere. :) - Surfin Bird

0