private string GetPage(string url, string username, string password, string domain)
{
//Create new Request
System.Net.HttpWebRequest request =
(System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
//Create proxy
System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
proxy.Credentials = new System.Net.NetworkCredential(username,password,domain);
request.Proxy = proxy;
//Get Response
System.Net.HttpWebResponse response =
(System.Net.HttpWebResponse)request.GetResponse();
System.IO.Stream stream = response.GetResponseStream();
//Start reading from the stream
byte[] buffer = new byte[256];
string retVal = string.Empty;
while (stream.Read(buffer,0,256) > 0)
{
retVal += System.Text.Encoding.ASCII.GetString(buffer);
}
stream.Close();
//Return the output
return retVal;
}
|