Identity Framework로 ASP.Net 응용 프로그램을 만들었습니다. 사용자 인증이 성공적으로 System.Web.HttpContext.Current.User.Identity
이 null
하고 System.Web.HttpContext.Current.User.Identity.IsAuthenticated
이 false
로그인 인증 후 사용자가 Null입니다.
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (!ModelState.IsValid)
{
return View(model);
}
var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: true);
switch (result)
{
case SignInStatus.Success:
ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
UserManager.AddClaim(User.Identity.GetUserId(),new Claim(ClaimTypes.Role,"Admin"));
후 나는 인증 후 인증 된 사용자에게 어떤 역할을 추가해야합니다.
첫 번째 리디렉션 후에 만 사용자 ID를 얻을 수 있습니다 – anand