Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

UserId is always 0 in Login in MVC4

$
0
0

I want to pass Userid with Email in Cookie but it always 0.

             if (user.IsValid(user.Email, user.Password))
                {

                    FormsAuthentication.SetAuthCookie(user.Email + "|" + user.Id, true);
                    return RedirectToAction("Index", "TestValidUser");
                }
public bool IsValid(string email, string password)
        {
            bool IsValid = false;
            var user = db.GistlerUsers.FirstOrDefault(u => u.Email == email);

            if (user != null)
            {

                if (user.Password == EncryptPassword(password))
                {
                    IsValid = true;

                }

            }
            return IsValid;
        }


user.Email has value but user.Id =0 always.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>