簡體   English   中英

Asp.Net Identity RTM版本中的Microsoft.AspNet.Identity.Owin.AuthenticationManager在哪里?

[英]Where is Microsoft.AspNet.Identity.Owin.AuthenticationManager in Asp.Net Identity RTM version?

我從這里安裝了AspNet-identity組件的每晚構建

似乎RC版本的AuthenticationManager類已從RTM版本( Microsoft.AspNet.Identity.Owin.1.0.0-rtm-130914 )中消失

它曾經在Microsoft.AspNet.Identity.Owin程序集中,但它不再存在。

此類具有以下方法: SignInAsyncCheckPasswordAndSignInAsync ,用於在使用個人用戶帳戶身份驗證創建新的ASP.Net Web應用程序MVC項目時獲得的默認項目。

AuthenticationManager現在在哪里? 或者用什么代替?

該類已經消失,因為它基本上只是添加生成ClaimsIdentity的方法並將其傳遞給Owin.Security.IAuthenticationManager。

相反,RTM模板在控制器中有一個SignIn方法,如下所示:

    private async Task SignInAsync(ApplicationUser user, bool isPersistent) {
        AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
        var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
        AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
    }

如果我錯了但沒有將AuthenticationManager移動到,那么有人會糾正我

HttpContext.Current.GetOwinContext().Authentication

所以上面的例子現在是這樣的:

private async Task SignInAsync(UserManager<User> manager, User user, bool isPersistent)
{
    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
    authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
    var identity = await manager.CreateIdentityAsync(user, DeffaultAuthenticationTypes.ApplicationCookie);
    authenticationManager.SignIn(new AuthenticationProperties(){ IsPersistent = isPersistent }, identity);
}

請注意,UserManager似乎不再具有靜態方法CreateIdentityAsync,因此必須從對象實例觸發。

除非我錯過了什么?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM