Has there been any change in Cookie behavior

Discussion in 'ASP .Net' started by cowznofsky, Mar 11, 2009.

  1. cowznofsky

    cowznofsky Guest

    Here is some code from an app written in VS2003

    'Cookie will be "in memory" only, not written to user's
    'PC. This happens by simply NOT specifying an
    'expiration time.
    Response.Cookies("OOI")("UserID") = Me.txtUserID.Text

    I've migrated the app to VS2008, and am getting an error ("Object
    reference not set to an instance of an object")when using this code on
    a separate page:

    sCookie = Request.Cookies("OOI")("UserID").ToString()


    Now, the code works (1) on my dev machine and (2) if I get onto the
    host server and get into IE and run it there.
    I get the error only when I connect to the app from another machine.
    Otherwise everything else works fine.

    Could there have been some change along the way from ASP.NET 1.1 to
    2.0?
     
    cowznofsky, Mar 11, 2009
    #1
    1. Advertising

  2. On Mar 11, 8:41 pm, cowznofsky <> wrote:
    > Here is some code from an app written in VS2003
    >
    >         'Cookie will be "in memory" only, not written to user's
    >         'PC. This happens by simply NOT specifying an
    >         'expiration time.
    >         Response.Cookies("OOI")("UserID") = Me.txtUserID.Text
    >
    > I've migrated the app to VS2008, and am getting an error ("Object
    > reference not set to an instance of an object")when using this code on
    > a separate page:
    >
    >         sCookie = Request.Cookies("OOI")("UserID").ToString()
    >
    > Now, the code works (1) on my dev machine and (2) if I get onto the
    > host server and get into IE and run it there.
    > I get the error only when I connect to the app from another machine.
    > Otherwise everything else works fine.
    >
    > Could there have been some change along the way from ASP.NET 1.1 to
    > 2.0?


    I think Request.Cookies("OOI")("UserID") returns null when cookies are
    not presented and you get an error because of this. Did you check
    before that line

    If Not Request.Cookies("OOI") Is Null And Not Request.Cookies("OOI")
    ("UserID") Is Null Then

    ....

    ?
     
    Alexey Smirnov, Mar 13, 2009
    #2
    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. Amanda
    Replies:
    26
    Views:
    960
    amanda
    Nov 11, 2006
  2. Metalone
    Replies:
    5
    Views:
    277
    Thomas Heller
    Oct 19, 2007
  3. bill.wu
    Replies:
    0
    Views:
    295
    bill.wu
    Jan 17, 2008
  4. Andrew Duffy

    Checking if a cookie has already been set

    Andrew Duffy, Oct 10, 2003, in forum: ASP General
    Replies:
    2
    Views:
    97
    Ray at
    Oct 10, 2003
  5. John Merlino
    Replies:
    0
    Views:
    211
    John Merlino
    Jan 1, 2011
Loading...

Share This Page