Has there been any change in Cookie behavior

  • Thread starter Thread starter cowznofsky
  • Start date Start date
C

cowznofsky

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?
 
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

....

?
 
Back
Top