WebRequest & Sessions

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top