can Webclient class be used with Session?

Discussion in 'ASP .Net' started by Guest, Oct 5, 2004.

  1. Guest

    Guest 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?
    Guest, Oct 5, 2004
    1. Advertisements

  2. Guest

    Scott Allen Guest

    Scott Allen, Oct 5, 2004
    1. Advertisements

  3. Guest

    Guest Guest

    Hi Scott,
    That is a good start. I still need to solve the problem with doing client
    requests with sessions.
    Guest, Oct 5, 2004
  4. Guest

    Scott Allen Guest

    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

    Make sense? Or am I misunderstanding your question?
    Scott Allen, Oct 5, 2004
  5. Guest

    Joerg Jooss Guest

    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.

    Joerg Jooss, Oct 8, 2004
  6. Guest

    Scott Allen Guest

    Thanks for the correction, I didn't have the sentenced properly
    worded. I apologize for any confusion.
    Scott Allen, Oct 8, 2004
  7. Guest

    Scott Allen Guest


    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

    My article discuses this very problem and gives a code example, so
    perhaps you had already figured this out.
    Scott Allen, Oct 8, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.