At the moment I am trying to HTTP response request in my Sharepoint WarmUp script, however for this, I will have to use this code
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);
}
I am not suppose to use any User Account to get response, however I can use Default Credentials that only works when am logged in at server, otherwise they wont gonna work i guess.
Is there any other way of doing it, can’t use powershell as its MOSS not sharepoint 2010
cheers
You CAN use Powershell for the warm-up script. You can call stsadm command, make HTTP requests and even use the server object model once you do the proper imports.
This post uses powershell to retrieve available sites using stsadm. Once the script retrieves this list, it instantiates a WebClient object and hits each site URL.
If you only want to hit the sites in a list, you can simply use a WebClient object to do this.