I am struggling with web requests to some websites like (mrporter.com or size.co.uk). Outside USA (so no USA IPs), I can make requests just fine. However once I am behind USA IP, requests either time out or end up with "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond" exception. I have tried all kind of headers combinations, still no luck. I need to note, that those websites are opening in browsers just fine.
This is my implementation that works with non-USA ips.
- var _request = (HttpWebRequest)WebRequest.Create("https://www.mrporter.com");
- _request.CookieContainer = new CookieContainer();
- _request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36";
- _request.KeepAlive = true;
- _request.AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate);
- _request.Headers.Add("Accept-Encoding", "gzip, deflate");
- _request.Headers.Add("Accept-Language", "en-GB, en-US; q=0.9, en; q=0.8");
- _request.Headers.Add("Upgrade-Insecure-Requests", "1");
-
- var _srr = "";
- using (var response = _request.GetResponse())
- {
- var httpWebResponse = response.GetResponseStream();
- using (var sr = new StreamReader(httpWebResponse))
- {
- _srr = sr.ReadToEnd();
- }
- }
Anybody can help? I seriously wasted hours with it with no result ...