开发者

why won't this web request go thru for valid website

Given the following why are the websites Not valid? I'm getting the follwoing error message.

try {
  HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(@"http://wrtire1.tru-m.com/");
  //2 websites that do this
  // http://wrtire1.tru-m.com/
  // http://acuraofaugusta.mobi/index.htm
  webReq.Method = "HEAD";    开发者_运维知识库 
  HttpWebResponse webRes = (HttpWebResponse)webReq.GetResponse();

  if (webRes.StatusCode == HttpStatusCode.OK) 
    Label1.Text = true.ToString();
} catch (Exception e) {
  Label1.Text = "The remote server returned an error: (403) Forbidden. ";
  // or I got this: The remote server returned an error: (500) Internal Server Error.
}

I received this error message

The remote server returned an error: (500) Internal Server Error.


This can happen because the web server has had a look at your HTTP Request's User Agent and denied access, because it knows your application is not a legitimate web browser.

Many websites do this to cut down on traffic from bots and web-crawlers.

Here's more information on the concept

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜