private IEnumerable<Claim> getUserClaims(Account account)
{
List<Claim> claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, account.Pos));
claims.Add(new Claim(ClaimTypes.Role, account.RidNavigation.Name)); //RidNavigationdu bozmak istemedim.
return claims;
}
I am trying to login but System.NullReferenceException: 'Object reference not set to an instance of an object.'
bilgiislemm.Models.Account.RidNavigation.get returned null. I am encountering the error. My codes in login controller are as follows
[HttpPost]
public IActionResult Index(Account p)
{
var account = db.Accounts.SingleOrDefault(a => a.Pos == p.Pos && a.Sif == p.Sif);
if (account != null)
{
SecurityManager securityManager = new SecurityManager();
securityManager.SignIn(this.HttpContext, account);
return RedirectToAction("Index", "Home");
}
else
{
ViewBag.error = "Hatalı";
return View();
}
}
When I run the application for the first time, when I try to log in with the correct information, I can log in. But after trying to enter with wrong information, when I try to enter with correct information again, I encounter this error.