【发布时间】:2014-07-30 23:10:10
【问题描述】:
我正在尝试从数据库 nvarchar(128) -> uniqueidentifier 和字符串 -> Guid 的代码中更改 asp.net 身份的 pk 系统。在此article 之后,基于将 pk 更改为 int32 我只有一个问题,我似乎无法解决。
在我的Startup.Auth.cs 课程中,我更改了以下内容
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{ //error on the line below
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser, Guid>(TimeSpan.FromMinutes(20), (manager, user) => user.GenerateUserIdentityAsync(manager), (identity) => Guid.Parse(identity.GetUserId()))
}
});
我遇到了两个我无法理解的错误。 Identity 的结构让我对这么多泛型感到困惑。我知道它说它接收到错误的参数类型,但我不知道如何解决这个问题。
错误
错误 1 最好的重载方法匹配 'Microsoft.AspNet.Identity.Owin.SecurityStampValidator.OnValidateIdentity(System.TimeSpan, System.Func>, System.Func)' 有 一些无效的参数
错误 2 参数 2:无法从“lambda 表达式”转换为 'System.Func>'
谁能提供一点见解?
【问题讨论】:
-
查看 IdentityModels、IdentityConfig 和 Startup.Auth 文件以了解如何实现它:Samples.PrimaryKeyGuid
标签: c# asp.net asp.net-mvc asp.net-identity