I have an AccountController with a Login action.
We SignIn the user in our Application Service like that:
_signInManager.AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = userDto.RememberMe }, identity);
After that I redirect the user to Home/Index.
In the Home/Index the User.IsAuthenticated is true
But before doing this redirection, in the AccountController, even after calling _signInManager.AuthenticationManager.SignIn(...) User.IsAuthenticated is false.
What are we doing wrong?
Problem is, that I need to unit test the AccountController and want to test if after calling _signInManager.AuthenticationManager.SignIn(...), the user is really signed in.
Thank you very much for the help
Daniel
EDIT:
After using this code:
ClaimsPrincipal principal = new ClaimsPrincipal(identity);
System.Threading.Thread.CurrentPrincipal = principal;
HttpContext.Current.User = principal;
Works fine, but smells weird!