Object reference error even when object is not null

Posted by Shrewd Demon on Stack Overflow See other posts from Stack Overflow or by Shrewd Demon
Published on 2010-05-27T08:34:46Z Indexed on 2010/05/27 8:41 UTC
Read the original article Hit count: 303

Filed under:
|
|

hi,

i have an application wherein i have incorporate a "Remember Me" feature for the login screen. I do this by creating a cookie when the user logs in for the first time, so next time when the user visits the site i get the cookie and load the user information.

i have written the code for loading user information in a common class in the App_Code folder...and all my pages inherit from this class.

code for loading the user info is as follows:

public static void LoadUserDetails(string emailId)
{
    UsersEnt currentUser = UsersBL.LoadUserInfo(emailId);

    if (currentUser != null)
        HttpContext.Current.Session["CurrentUser"] = currentUser;
}

Now the problem is i get an "Object reference" error when i try to store the currentUser object in the session variable (even though the currentUser object is not null). However the password property in the currentUser object is null.

Am i getting the error because of this...or is there some other reason??

thank you

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET