Method:
public RequestTest Test(string url)
{
var test = new RequestTest() { Url = url };
var sw = new Stopwatch();
var request = WebRequest.CreateHttp(test.Url);
request.AllowAutoRedirect = true;
request.Method = "HEAD";
request.UserAgent = "Accept-Language: en-US,en;q=0.5";
try
{
sw.Start();
using (var response = (HttpWebResponse)request.GetResponse())
{
sw.Stop();
test.Time = (int)sw.ElapsedMilliseconds;
test.StatusCode = response.StatusCode;
}
return test;
}
catch (WebException ex)
{
test.StatusCode = ((HttpWebResponse)ex.Response).StatusCode;
return test;
}
}
URL is http://monosnap.com/page/faq , which must be redirected to the some language area, for example - http://monosnap.com/ru/page/faq
But it throws WebException, with Message "The remote name could not be resolved: 'page'".
UPD: I add useragent
request.UserAgent = "Accept-Language: en-US,en;q=0.5";
But I still get the same exception "The remote name could not be resolved: 'page'" Also, redirect works properly from my browser. So, problem is in code.