Has there been any change in Cookie behavior

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

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?

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

....

?
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top