目前我正在尝试在我的 Sharepoint WarmUp 脚本中响应 HTTP 请求,但是为此,我将不得不使用此代码
using (System.IO.StreamReader file = new System.IO.StreamReader(filePath))
while ((line = file.ReadLine()) != null)
{
try
{
WebRequest request = WebRequest.Create(line);
request.Proxy = null;
if ((userName == null) || (userName == ""))
{
request.Credentials = CredentialCache.DefaultCredentials;
}
else
{
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(line), "NTLM", new NetworkCredential(userName, password, DomainName));
request.Credentials = myCache;
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (Stream dataStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(dataStream))
{
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
}
Thread.Sleep(2000);
}
我不应该使用任何用户帐户来获得响应,但是我可以使用只有在服务器登录时才有效的默认凭据,否则我猜他们不会工作。
有没有其他方法可以使用powershell作为它的MOSS而不是sharepoint 2010
干杯