asp.net - 无法在成功进行自定义身份验证后在owin中设置Identity

时间:2016-01-25 19:13:57

标签: asp.net wcf asp.net-identity forms-authentication session-cookies

我正在使用wcf服务进行身份验证和与数据库的通信。成功验证后,在客户端Web应用程序中,我尝试使用以下代码为登录用户设置Identity。

    private async Task SignIn(ApplicationUser user)
    {
        var identity = await UserManager.CreateIdentityAsync(
            user, DefaultAuthenticationTypes.ApplicationCookie);

        GetAuthenticationManager().SignIn(identity);
    }

    private IAuthenticationManager GetAuthenticationManager()
    {
        var ctx = Request.GetOwinContext();
        return ctx.Authentication;
    }

即使在执行上述代码之后,即设置标识Request.IsAuthenticated仍然返回false。

我发现上面的代码在使用Microsoft.AspNet.Identity.Core版本1.0.0库的在线sample中运行良好。

知道我做错了吗?

0 个答案:

没有答案