whille checking http status code getting error saying - The remote server returned an error: (503) Server Unavailable

whille checking http status code getting error saying - The remote server returned an error: (503) Server Unavailable

如果 url 有效,我想插入 url/link。为此我正在检查状态代码。但是对于某些 link 来说,即使它是有效的 link

,我也会遇到这个错误
    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(LinkCheck);
    myHttpWebRequest.Timeout = 150000;
    myHttpWebRequest.Method = "HEAD";
    myHttpWebRequest.UserAgent = "Foo";
    myHttpWebRequest.Accept = "*/*";
    myHttpWebRequest.AllowAutoRedirect = false;
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();//getting error here
    MyStatusCode = ((int)myHttpWebResponse.StatusCode);
    myHttpWebResponse.Close();

输入- http://www.jabong.com/men/ 输出应该来= 200 但它的抛出错误

您向其发出请求的 server 似乎不支持 HEAD HTTP 动词。将您的请求更改为 GET,它将正常工作:

myHttpWebRequest.Method = "GET";