【发布时间】:2015-01-04 18:54:03
【问题描述】:
我已按照http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity 中的说明更改了 PK,但是在我尝试登录后,我收到以下错误。登录部分成功,因为“this”包含所有适当的数据,但是创建身份似乎失败
从具体化的“System.String”类型到“System.Int32”类型的指定转换无效。
在线上
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
方法
public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole, CustomUserClaim>
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, int> 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;
}
public string FirstName { get; set; }
public string LastName { get; set; }
}
【问题讨论】:
-
你有 ApplicationUserManager 类,它包含 Startup.cs 上的所有配置和 CreatePerOwinContext 吗?
标签: c# asp.net-identity