我做了一个基本的 ASP.Net MVC Web 项目。我使用 Microsoft 文档将我的所有 ID 从string转换为一个。int
https://learn.microsoft.com/en-us/aspnet/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity#run
我做了这些更改 + MVC Update 3 更改。当我编译并运行我的新项目时,它int在我的文件中显示为一个,但我收到错误并且无法完成运行该项目。
这是我的消息在输出中显示的内容:
抛出的异常:mscorlib.dll 中的“System.FormatException” mscorlib.dll 中出现“System.FormatException”类型的异常,但未在用户代码中处理 输入字符串的格式不正确。
任何输入将不胜感激。我确实运行了迁移,它显示为int但没有在我的浏览器中完全运行。
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/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, ApplicationUser, int>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) =>
user.GenerateUserIdentityAsync(manager),
getUserIdCallback:(id)=>Int32.Parse(id.GetUserId()))
}
});
我的代码在这部分中断了,那就是异常 id.GetUserId()
这是在 startup.auth.cs
谢谢你。
吃鸡游戏
跃然一笑
相关分类