Visual Studio 2015 将 AspNet.Identity 移入 class 图书馆
Visual Studio 2015 Moving AspNet.Identity into class library
我在 VS 2013 中多次将 AspNet.Identity 移动到 class 库中,但在 VS 2015 中,编译器抱怨管理器参数抛出此异常
The type 'MyNamespace.ApplicationUser' cannot be used as type parameter 'TUser' in the generic type or method 'UserManager'. There is no implicit reference conversion from 'MyNamespace.ApplicationUser' to '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;
}
}
我所有的引用和使用语句都是一样的。
怎么回事?
我认为你必须让你的 ApplicationUser 继承自 IdentityUser。
我在 VS 2013 中多次将 AspNet.Identity 移动到 class 库中,但在 VS 2015 中,编译器抱怨管理器参数抛出此异常
The type 'MyNamespace.ApplicationUser' cannot be used as type parameter 'TUser' in the generic type or method 'UserManager'. There is no implicit reference conversion from 'MyNamespace.ApplicationUser' to '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;
}
}
我所有的引用和使用语句都是一样的。
怎么回事?
我认为你必须让你的 ApplicationUser 继承自 IdentityUser。