M
M
martensit2018-12-05 19:19:38
Windows
martensit, 2018-12-05 19:19:38

Can't send a get request in c# .NET 2.0, what's wrong?

Windows XP SP3 + .NET Framework 2.0 SP2
Error 0xe0434f4d

string rs = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://2ip.ru/");
req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
req.Method = "GET";
req.KeepAlive = true;
req.Headers.Add("Upgrade-Insecure-Requests", "1");
req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
req.Headers.Add("Accept-Encoding", "gzip, deflate, br");
req.Headers.Add("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7");
req.Timeout = 10000;
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
rs = reader.ReadToEnd();
response.Close();

394LCOkZ9B.jpg
On Windows 7, the compiled EXE runs fine,
On Windows XP, the same EXE file pops up with an error.
5c08014a2bb78168046443.png
EventType : clr20r3 P1 : test_2.0.exe P2 : 1.0.0.0 P3 : 8bfd9a43
P4 : system P5 : 2.0.0.0 P6 : 4889de7a P7 : 1f6d P8 : 1bd
P9 : system.net.webexception

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2018-12-05
@Sumor

req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

There is no support for this in Windows XP.
To get a complete error, don't forget to frame the try-catch and display the full text of the message, which will tell you the reason for the error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question