瀏覽代碼

访问服务修改

新疆警官学校中职
zhangli 1 年之前
父節點
當前提交
b887b6d41a
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. +3
    -3
      Learun.Framework.Ultimate V7/VisitService/Service1.cs

+ 3
- 3
Learun.Framework.Ultimate V7/VisitService/Service1.cs 查看文件

@@ -53,7 +53,6 @@ namespace VisitService
fs.Close();
}

System.GC.Collect();
var url = System.Configuration.ConfigurationManager.AppSettings["cyapi"].ToString();
var arr = url.Split(';');
foreach (var item in arr)
@@ -62,16 +61,17 @@ namespace VisitService
{
System.IO.File.AppendAllText(logPath_timer,
"\r\n" + DateTime.Now + "\r\n开始访问:" + item);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.KeepAlive = false;
myRequest.Method = "HEAD"; //设置提交方式可以为"get","head"等
myRequest.Timeout = 30000; //设置网页响应时间长度
//myRequest.Timeout = 60000; //设置网页响应时间长度
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);
myResponse.Dispose();
}
catch (Exception ex)
{


Loading…
取消
儲存