gpt4 book ai didi

asp.net - 如何在没有 aspnet 身份的情况下使用 OWIN 表单例份验证

转载 作者:行者123 更新时间:2023-12-02 09:35:48 25 4
gpt4 key购买 nike

我想使用 OWIN 管道向客户端发出身份验证 cookie,在用户注销时清除 cookie 等,但我不想使用烦人的 aspnet 身份提供程序。它只是不适合这个项目,我尝试了很长时间,但它就是不适合。所以我决定不再使用它。我只想使用 OWIN 管道。

这可能吗,或者我应该回退到旧的表单例份验证?

最佳答案

像这样吗?

var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, "Brock"));
claims.Add(new Claim(ClaimTypes.Email, "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3351415c5058525f5f565d73545e525a5f1d505c5e" rel="noreferrer noopener nofollow">[email protected]</a>"));
var id = new ClaimsIdentity(claims,
DefaultAuthenticationTypes.ApplicationCookie);

var ctx = Request.GetOwinContext();
var authenticationManager = ctx.Authentication;
authenticationManager.SignIn(id);

取自 here .

关于asp.net - 如何在没有 aspnet 身份的情况下使用 OWIN 表单例份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26476765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com