Home > Net >  About whether the URL effective method, is not very accurate
About whether the URL effective method, is not very accurate

Time:10-05

HttpWebRequest myRequest=(HttpWebRequest) WebRequest. Create (strUrl);
MyRequest. Method="HEAD";
MyRequest. Timeout=10000;//timeout 10 seconds
MyRequest. UseDefaultCredentials=true;
HttpWebResponse res=(HttpWebResponse) myRequest. The method GetResponse ();
Return (res) StatusCode==HttpStatusCode) OK);

Above is to determine whether a URL can normal access code, but for some URL validation is not very accurate,
More accurate method to judge each master?

CodePudding user response:

What's not, please illustrate,
Itself "the URL is valid" is a fuzzy concept, the website can be part of the IP/request type/no users return an error, or does not return, may also can be accessed at this time, later can't,

CodePudding user response:

Looks like there is no problem, the condition of HttpStatusCode telling ah
  •  Tags:  
  • C #
  • Related