To get this to work in ASP.NET Core, first, use NuGet to add Microsoft.AspNetCore.Authentication.Cookies
In Startup.cs, add this to the Configure method:
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "PutANameHere",
LoginPath = new PathString("/Account/Login/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
Then call this to login:
var userClaims = new List<Claim>
{
new Claim(ClaimTypes.Name, userName)
};
var principal = new ClaimsPrincipal(new ClaimsIdentity(userClaims, "local"));
HttpContext.Authentication.SignInAsync("PutANameHere", principal);
For more information on this, check this out:
https://docs.asp.net/en/latest/security/authentication/cookie.html