HttpWebRequest With Session

Y

yoni

Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks
 
N

Nicholas Paldino [.NET/C# MVP]

What you need to do is in the response for the first request, there will
be cookies that are sent back. You need to include these cookies as part of
your second request. One of these cookies has an identifier in it which
idenfies the session.

Hope this helps.
 
Y

yoni

This sure helps! what would help more is if you can refer me to any
code sample where its done... do you have anything off the top of your
head... either the online help, an MSDN article or anything like that
where they talk about it? thanks!
Nicholas said:
What you need to do is in the response for the first request, there will
be cookies that are sent back. You need to include these cookies as part of
your second request. One of these cookies has an identifier in it which
idenfies the session.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks
 
N

Nicholas Paldino [.NET/C# MVP]

Take a look at the CookieContainer property on the HttpWebRequest. You
should be able to assign a new CookieContainer instance to it. Then, the
response should populate a cookie collection in the container. Just make
sure that you store a reference to the CookieContainer so that you can
assign it to the new request.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

This sure helps! what would help more is if you can refer me to any
code sample where its done... do you have anything off the top of your
head... either the online help, an MSDN article or anything like that
where they talk about it? thanks!
Nicholas said:
What you need to do is in the response for the first request, there will
be cookies that are sent back. You need to include these cookies as part
of
your second request. One of these cookies has an identifier in it which
idenfies the session.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,
I am using HttpWebRequest to get the content of a web page. the call to
this web page is creating a session on the server. then, I wish to get
the content of a 2nd web page on the same site, but this 2nd web page
reads the session created on the 1st page. so when i call it with
HttpWebRequest, it lost the session. anybody has a tip or a code
snippet that shows me how do i make the server retain the session
between two HttpWebRequest calls?

thanks
 

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