WebRequest & Sessions

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

Hi there,

I'm trying to 'browse' a website using the HttpWebRequest class by calling
the following function (webRequest is declared outside the function):
private string GetHtml(string sUrl)
{
string sResult;

WebResponse objResponse;
webRequest = (HttpWebRequest)WebRequest.Create(sUrl);

webRequest.KeepAlive = true;
webRequest.Method = "GET";
objResponse = webRequest.GetResponse();

StreamReader sReader = new StreamReader(objResponse.GetResponseStream(),
System.Text.Encoding.UTF7);
sResult = sReader.ReadToEnd();
sReader.Close();

return (sResult);
}

The problem I have is that the session does not stay alive, i.e. each time I
connect to the same site (different page), it views me as a new visitor and
the session info is cleared.
Is there a way to get around this?

Thanx
Ron
 
Back
Top