Adr*_*ian 5 c# asp.net asp.net-mvc asp.net-identity
我试图从数据库nvarchar(128) - > uniqueidentifier和string - > Guid的代码中更改asp.net身份的pk系统.根据这篇文章基于将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()))
}
});
Run Code Online (Sandbox Code Playgroud)
我得到两个我无法理解的错误.身份的结构使我与许多仿制药混淆了.我理解它说接收错误的参数类型,但我不知道如何解决这个问题.
错误
错误1"Microsoft.AspNet.Identity.Owin.SecurityStampValidator.OnValidateIdentity(System.TimeSpan,System.Func>,System.Func)"的最佳重载方法匹配具有一些无效参数
错误2参数2:无法从'lambda表达式'转换为'System.Func>'
任何人都可以提供一点见解吗?
小智 11
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/_layouts/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, WebUser,Guid>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) =>
user.GenerateUserIdentityAsync(manager),
getUserIdCallback:(id)=>(Guid.Parse(id.GetUserId())))
}
});
Run Code Online (Sandbox Code Playgroud)