can Webclient class be used with Asp.net Session?

G

Guest

I trying to create a test harness for a website using the webclient class. I
don't understand how I can maintain a login session with this approach.
Dim wc as new webclient
wc.adHeader("cockies","ginger=snap") ' Will this work?
How can I open a secure page that requires a login?
 
G

Guest

Hi Scott,
That is a good start. I still need to solve the problem with doing client
requests with asp.net sessions.
Thanks.
 
S

Scott Allen

Hi Arne:

One you have the CookieContainer setup, you need to keep attaching the
cookies to subsequent requests. When ASP.NET sees the request it can
read the SessionID cookie and hook the request up to the appropriate
session.

Make sense? Or am I misunderstanding your question?
 
J

Joerg Jooss

Scott said:
Hi Arne:

One you have the CookieContainer setup, you need to keep attaching the
cookies to subsequent requests.

Actually, no. The FCL internally copies all "Set-Cookie" and "Set-Cookie2"
headers to the cookie container automatically, so manual copying isn't
required. Just make sure to reuse the same CookieContainer instance within a
web conversation.

Cheers,
 
S

Scott Allen

Thanks for the correction, I didn't have the sentenced properly
worded. I apologize for any confusion.
 
S

Scott Allen

Arne:

Let me rephrase my last response because it seems as if it caused some
confusion among other readers.

Where I said "keep attaching the cookies", I should say explicitly
that the CookieContainer instance from the first request needs to be
attached to subsequent requests by assigning a reference to the Cookie
property.

My article discuses this very problem and gives a code example, so
perhaps you had already figured this out.
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top