can Webclient class be used with Asp.net Session?

Discussion in 'ASP .Net' started by =?Utf-8?B?QXJuZQ==?=, Oct 5, 2004.

  1. 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?
    =?Utf-8?B?QXJuZQ==?=, Oct 5, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?QXJuZQ==?=

    Scott Allen Guest

    Hi Arne:

    You'll need to add an instance of the CookieCollection class to the
    Cookies property.

    My article here has an example of using the class:
    http://odetocode.com/Articles/162.aspx

    --
    Scott
    http://www.OdeToCode.com/

    On Tue, 5 Oct 2004 08:11:01 -0700, "Arne"
    <> wrote:

    >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?
    Scott Allen, Oct 5, 2004
    #2
    1. Advertising

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

    "Scott Allen" wrote:

    > Hi Arne:
    >
    > You'll need to add an instance of the CookieCollection class to the
    > Cookies property.
    >
    > My article here has an example of using the class:
    > http://odetocode.com/Articles/162.aspx
    >
    > --
    > Scott
    > http://www.OdeToCode.com/
    >
    > On Tue, 5 Oct 2004 08:11:01 -0700, "Arne"
    > <> wrote:
    >
    > >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?

    >
    >
    =?Utf-8?B?QXJuZQ==?=, Oct 5, 2004
    #3
  4. =?Utf-8?B?QXJuZQ==?=

    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
    session.

    Make sense? Or am I misunderstanding your question?

    --
    Scott
    http://www.OdeToCode.com/

    On Tue, 5 Oct 2004 13:37:03 -0700, "Arne"
    <> wrote:

    >Hi Scott,
    >That is a good start. I still need to solve the problem with doing client
    >requests with asp.net sessions.
    >Thanks.
    >
    >"Scott Allen" wrote:
    >
    >> Hi Arne:
    >>
    >> You'll need to add an instance of the CookieCollection class to the
    >> Cookies property.
    >>
    >> My article here has an example of using the class:
    >> http://odetocode.com/Articles/162.aspx
    >>
    >> --
    >> Scott
    >> http://www.OdeToCode.com/
    >>
    >> On Tue, 5 Oct 2004 08:11:01 -0700, "Arne"
    >> <> wrote:
    >>
    >> >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?

    >>
    >>
    Scott Allen, Oct 5, 2004
    #4
  5. =?Utf-8?B?QXJuZQ==?=

    Joerg Jooss Guest

    Scott Allen wrote:
    > 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,

    --
    Joerg Jooss
    www.joergjooss.de
    Joerg Jooss, Oct 8, 2004
    #5
  6. =?Utf-8?B?QXJuZQ==?=

    Scott Allen Guest

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

    --
    Scott
    http://www.OdeToCode.com/

    On Fri, 8 Oct 2004 18:01:03 +0200, "Joerg Jooss" <>
    wrote:

    >Scott Allen wrote:
    >> 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,
    Scott Allen, Oct 8, 2004
    #6
  7. =?Utf-8?B?QXJuZQ==?=

    Scott Allen Guest

    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.

    --
    Scott
    http://www.OdeToCode.com/


    On Tue, 5 Oct 2004 13:37:03 -0700, "Arne"
    <> wrote:

    >Hi Scott,
    >That is a good start. I still need to solve the problem with doing client
    >requests with asp.net sessions.
    >Thanks.
    >
    >"Scott Allen" wrote:
    >
    >> Hi Arne:
    >>
    >> You'll need to add an instance of the CookieCollection class to the
    >> Cookies property.
    >>
    >> My article here has an example of using the class:
    >> http://odetocode.com/Articles/162.aspx
    >>
    >> --
    >> Scott
    >> http://www.OdeToCode.com/
    >>
    >> On Tue, 5 Oct 2004 08:11:01 -0700, "Arne"
    >> <> wrote:
    >>
    >> >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?

    >>
    >>
    Scott Allen, Oct 8, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Smythe
    Replies:
    3
    Views:
    1,215
    Jeff Smythe
    Jan 2, 2004
  2. far asl via DotNetMonster.com

    How can i share asp session data with asp.net session data

    far asl via DotNetMonster.com, Mar 22, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    534
    =?Utf-8?B?VmliaHUgQmFuc2Fs?=
    Mar 23, 2005
  3. Replies:
    1
    Views:
    691
  4. kellygreer1

    ASP.NET and Security Issues with WebClient

    kellygreer1, Mar 4, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,939
    kellygreer1
    Mar 5, 2008
  5. Casey Hawthorne
    Replies:
    1
    Views:
    687
    Arne Vajhøj
    Mar 18, 2009
Loading...

Share This Page