首页 > 代码库 > sharepoint warmup
sharepoint warmup
/---------------- using System;using System.Collections.Generic;using System.Text;using System.Net;namespace WarmupSharepointCS{ class Program { static void Main(string[] args) { string url = "https://www.sp.net"; string url2 = "https://www.sp.net/_windows/default.aspx?ReturnUrl="; string user = "user"; string pwd = @"pwd"; long count = 0; System.Threading.Timer t = new System.Threading.Timer(callback => { if (System.DateTime.Now.Hour >= 5 && System.DateTime.Now.Hour < 21) try { string authInfo = user + ":" + pwd; authInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo)); var webclient = new WebClient2(); webclient.Headers[HttpRequestHeader.Authorization] = "Basic " + authInfo; var webpage = webclient.DownloadString(url2); var str2 = webclient.DownloadString(url); Console.ForegroundColor = System.ConsoleColor.Green; Console.WriteLine(webpage); } catch (Exception ex) { Console.ForegroundColor = System.ConsoleColor.Red; Console.WriteLine(ex.Message); } count++; Console.WriteLine("timer:" + count.ToString()); },null,0,1000*60 * 20); Console.Read(); } }} //---------------- ///////////////////////////////using System;using System.Collections.Generic;using System.Net;namespace WarmupSharepointCS{ public class WebClient2:System.Net.WebClient { private readonly CookieContainer m_container = new CookieContainer(); protected override WebRequest GetWebRequest(Uri address) { WebRequest request = base.GetWebRequest(address); HttpWebRequest webRequest = request as HttpWebRequest; if (webRequest != null) { webRequest.CookieContainer = m_container; } return request; } }} //////////////////////////////////
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。