【问题标题】:How to use OWIN forms authentication without aspnet identity如何在没有 aspnet 身份的情况下使用 OWIN 表单身份验证
【发布时间】:2014-10-20 23:51:21
【问题描述】:

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

这是可能的还是我应该回退到旧的表单身份验证?

【问题讨论】:

    标签: asp.net asp.net-mvc forms forms-authentication owin


    【解决方案1】:

    像这样?

    var claims = new List<Claim>();
    claims.Add(new Claim(ClaimTypes.Name, "Brock"));
    claims.Add(new Claim(ClaimTypes.Email, "brockallen@gmail.com"));
    var id = new ClaimsIdentity(claims,
                                DefaultAuthenticationTypes.ApplicationCookie);
    
    var ctx = Request.GetOwinContext();
    var authenticationManager = ctx.Authentication;
    authenticationManager.SignIn(id);
    

    取自here。

    【讨论】:

    • DefaultAuthenticationTypes 是身份的一部分 (Microsoft.AspNet.Identity.DefaultAuthenticationTypes)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 2022-01-03
    • 2022-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    相关资源
    最近更新 更多