我现在正在进行.Net Core项目,我需要接口的AuthenticationManager,也就是IAuthenticationManager
根据微软的文档(此处),这已经过时了。
要获取ApplicationSignInManager,我有以下方法:
private ApplicationSignInManager getSignInManager(ApplicationUserManager manager, IAuthenticationManager auth)
{
return new ApplicationSignInManager(manager, auth);
}
应用程序登录管理器
public class ApplicationSignInManager : SignInManager<ApplicationUser, string>
{
public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
: base(userManager, authenticationManager)
{
}
public static ApplicationSignInManager Create(IdentityFactoryOptions<ApplicationSignInManager> options, IOwinContext context)
{
return new ApplicationSignInManager(context.GetUserManager<ApplicationUserManager>(), context.Authentication);
}
}
由于使用了CreatePerOwinContext,在Mvc项目中这是有效的。
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
但是如何在 .Net Core 中激活这个类呢?
同时在这里了解到,在 .Net Core 中这个 CreateOwinContext 已经过时了(参考链接),但我不知道如何调用 ApplicationSignInManager 的 create 方法。