OWIN/Identity 2.0 - تغيير pk من السلسلة إلى GUID
-
21-12-2019 - |
سؤال
أحاول تغيير نظام pk الخاص بهوية asp.net من قاعدة البيانات nvarchar(128) -> المعرف الفريد وفي التعليمات البرمجية من السلسلة -> Guid.تتبع هذا شرط بناءً على تغيير 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()))
}
});
وأتلقى خطأين لا أستطيع فهمهما.إن بنية الهوية تخلط بيني وبين الكثير من الأدوية الجنيسة.أفهم أنه يتلقى نوع المعلمة الخاطئ ولكن ليس لدي أي فكرة عن كيفية معالجة المشكلة.
أخطاء
خطأ 1 تتوافق أفضل طريقة تم تحميلها على "microsoft.aspnet.identity.owin.securitystampvalidator.onvalidityIdentity (System.Timespan ، system.func> ، system.func) ''
الخطأ 2 الوسيطة 2:لا يمكن تحويلها من "تعبير Lambda" إلى "system.func>"
يمكن لأي شخص أن يقدم القليل من البصيرة؟
المحلول
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())))
}
});
لا تنتمي إلى StackOverflow