Today suddenly comes out a problem, URL address calls cause the program to die (because the service hangs, the disk is broken)
Then think of, and then call the URL address before the first to determine whether the address is a response, so that can not solve the problem?
C # code:
/// <summary>///detect if URL addresses are accessible/// </summary>/// <param name= "Url" >URL address (starting with HTTP//)</param>/// <returns>return to OK</returns>/// <example>isurlvist ("http://www.baidu.com")</example> Public Static stringIsurlvisit (stringUrl) { stringRevlue =NULL; HttpWebRequest Request= (HttpWebRequest) webrequest.create (NewUri (URL)); Servicepointmanager.expect100continue=false; Try{(httpwebresponse) request. GetResponse ()). Close (); Revlue="OK"; } Catch(WebException ex) {Revlue=Ex. ToString (); } returnRevlue;}
Detects if a URL address is responding