我需要模拟对页面的请求,但我需要通过代码来模拟它。我正在使用这段代码,但没有得到好的结果
private string RemoteURLChecking(string url)
{try{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "HEAD";
request.Timeout = 8000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (!response.ResponseUri.ToString().ToLower().Contains("pagenotfound"))
return "The page exists";
else
return "Page not Found";
}
catch (Exception ex)
{
return "Page not Found";
}
}
谢谢