Possible unintended reference comparison

S

sotec

erroe message and code portion is like this....
how can i change this code to not occur to error

if (page.Session["UserId"] == null || page.Session["UserId"] !=
userId )
{
UserStatusSetting(page, userId);
}

Warning 2 Possible unintended reference comparison; to get a value
comparison, cast the left hand side to type 'string'
c:\inetpub\wwwroot\Minks\App_Code\SessionManager\SiteSessionManager.cs 28 51
http://localhost/Minks/
 
G

Guest

Sotec,
When you refer to an object that is stored in Session State, it doesn't
^automatically^ assume its initial type from when you stored it there. So
for example, (if your userId is a string) you could use
(string)page.Session["UserId"] and now you would be comparing a string to a
string.
Hope that helps.
Peter
 

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,230
Latest member
LifeBoostCBD

Latest Threads

Top