[英]How to set a Auth cookie in asp.net 5
試圖在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");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.