尝试在 asp.net5 中制作一种非常简单的身份验证形式,但似乎他们删除了表单例份验证。我还可以使用什么来进行非常简单的身份验证?
提前致谢
最佳答案
你可以这样做。
if (authUser.Username == "admin" && authUser.Password == "admin")
{
var claims = new[] { new Claim("name", authUser.Username), new Claim(ClaimTypes.Role, "Admin") };
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
Context.Authentication.SignIn(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity));
return Redirect("~/Home/Index");
}
关于authentication - 如何在 asp.net 5 中设置 Auth cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32373211/