FormsAuthentication に UserId がないので、それを渡したいと思います。ここに私のコードがあります
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");
}
今の問題は、user.Id
常に 0 であるということですFormsAuthentication.SetAuthCookie()
どうすれば設定できますか?