I am attempting to change asp.net identity's pk system from database nvarchar(128) -> uniqueidentifier and in code from string -> Guid. Following this article based on changing the pk to an int32 I have just one problem I can't seem to get around.
In my Startup.Auth.cs
class I have changed the following
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()))
}
});
and am getting two errors that I cannot comprehend. The structure of Identity confuses the hell out of me with so many generics. I understand it says it is receiving the wrong parameter type but I have no idea how to remedy the issue.
Errors
Error 1 The best overloaded method match for 'Microsoft.AspNet.Identity.Owin.SecurityStampValidator.OnValidateIdentity(System.TimeSpan, System.Func>, System.Func)' has some invalid arguments
Error 2 Argument 2: cannot convert from 'lambda expression' to 'System.Func>'
Can anyone offer a little insight?
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())))
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With