में साइन इन नहीं कर रहा है मैं डेटाबेस से वैध उपयोगकर्ता प्राप्त कर सकता हूं, ClaimsIdentity
और SignIn
विधि को त्रुटि के बिना बुलाया जाता है।प्रमाणीकरण प्रबंधक। साइनइन()
public ActionResult SignInConformation(SignInModel model)
{
if (ModelState.IsValid)
{
var user = _userManager.Find(model.Username, model.Password);
if (user == null)
{
ModelState.AddModelError("", "Invalid username and\\or password");
}
else
{
_authenticationManager.SignOut();
var claimsIdentity = _userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
_authenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, claimsIdentity);
return RedirectToAction("Index", "Home");
}
}
return View();
}
हालांकि
, जब मैं जाँच करता है, तो उपयोगकर्ता इस तरह दृश्य पर प्रवेश किया गया है:
<p>
Current User: @if (User.Identity.IsAuthenticated)
{
@User.Identity.Name
}
else
{
@:Unknown
}
</p>
IsAuthenticated
रिटर्न false
।