Visual Studio 2015将AspNet.Identity移动到类库中

时间:2015-10-16 09:10:25

标签: c# visual-studio-2015 asp.net-identity

我在VS 2013中多次将AspNet.Identity移动到类库中,但在VS 2015中,编译器抱怨执行该参数的manager参数

  

类型'MyNamespace.ApplicationUser'不能在泛型类型或方法'UserManager'中用作类型参数'TUser'。从'MyNamespace.ApplicationUser'到'Microsoft.AspNet.Identity.IUser

没有隐式引用转换

在此代码中:

public class ApplicationUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }
}

我所有的推荐和使用陈述都是一样的。

发生了什么事?

1 个答案:

答案 0 :(得分:2)

我认为您必须使您的ApplicationUser继承自IdentityUser。