As we do not have UserId in FormsAuthentication So i want to pass with it.Here is my code
public bool IsValid(string email, string password)
{
bool IsValid = false;
var user = db.Users.FirstOrDefault(u => u.Email == email);
if (user != null)
{
if (user.Password == EncryptPassword(password))
{
IsValid = true;
}
}
return IsValid;
}
if (user.IsValid(user.Email, user.Password))
{
FormsAuthentication.SetAuthCookie(user.Email + "|" + user.Id, true);
return RedirectToAction("Index", "TestValidUser");
}
Now Issue is that user.Id
is always 0 in FormsAuthentication.SetAuthCookie()
How I can set it?