ASP.NET OWIN UseCookieAuthentication Logs User Out After Sign In
I have a need to do manual cookie authentication. As I use OWIN with UseCookieAuthentication middleware, it is not that hard except when I had no idea what is actually required. I know I had to create a ClaimsIdentity and I will need AuthenticationProperties object. Supplying both of them successfully created the cookie, but when I went to a different page, the authentication failed and the application kicked me out to the login page. The following is my initial problematic code in the authentication handler: Dim claims As New List(Of Claim) claims.Add(New Claim(ClaimTypes.NameIdentifier, user.Username)) Dim claimsIdentity As New ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationType) context.GetOwinContext().Authentication.SignIn(New AuthenticationProperties With { .ExpiresUtc = expiration }, claimsIdentity) For my basic requirement, apparently there are required claims. In my case, I'm missing the Name claim. Adding the following claim solves my iss...