|
|
@@ -55,16 +55,29 @@ namespace VisitService |
|
|
|
|
|
|
|
System.GC.Collect(); |
|
|
|
var url = System.Configuration.ConfigurationManager.AppSettings["cyapi"].ToString(); |
|
|
|
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); |
|
|
|
myRequest.KeepAlive = false; |
|
|
|
myRequest.Method = "HEAD"; //设置提交方式可以为"get","head"等 |
|
|
|
myRequest.Timeout = 30000; //设置网页响应时间长度 |
|
|
|
myRequest.AllowAutoRedirect = false; //是否允许自动重定向 |
|
|
|
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); |
|
|
|
// return (myResponse.StatusCode == HttpStatusCode.OK);//返回响应的状态 |
|
|
|
var arr = url.Split(';'); |
|
|
|
foreach (var item in arr) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); |
|
|
|
myRequest.KeepAlive = false; |
|
|
|
myRequest.Method = "HEAD"; //设置提交方式可以为"get","head"等 |
|
|
|
myRequest.Timeout = 30000; //设置网页响应时间长度 |
|
|
|
myRequest.AllowAutoRedirect = false; //是否允许自动重定向 |
|
|
|
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); |
|
|
|
// return (myResponse.StatusCode == HttpStatusCode.OK);//返回响应的状态 |
|
|
|
|
|
|
|
System.IO.File.AppendAllText(logPath_timer, |
|
|
|
"\r\n" + DateTime.Now + "\r\n访问结果:" + myResponse.StatusCode); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
System.IO.File.AppendAllText(logPath_timer, |
|
|
|
"\r\n" + DateTime.Now + "\r\n访问结果异常,异常信息:" + ex.Message + ",访问地址:" + item); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
System.IO.File.AppendAllText(logPath_timer, |
|
|
|
"\r\n" + DateTime.Now + "\r\n访问结果:" + myResponse.StatusCode); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|