gpt4 book ai didi

c# - 输入字符串的格式不正确 - 使用了错误的上下文

转载 作者:行者123 更新时间:2023-11-30 22:52:14 25 4
gpt4 key购买 nike

在将 ASP.NET Core Identity 更改为使用 int 而不是 GUID 之后(根据 this blog post),我收到以下错误:

ArgumentException: 395438ed-1cd9-4420-8a58-3f3b1f550bfc is not a valid value for Int32. Parameter name: value System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) Microsoft.AspNetCore.Identity.UserStoreBase.ConvertIdFromString(string id) Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore.FindByIdAsync(string userId, CancellationToken cancellationToken) Microsoft.AspNetCore.Identity.UserManager.FindByIdAsync(string userId) Microsoft.AspNetCore.Identity.UserManager.GetUserAsync(ClaimsPrincipal principal) Microsoft.AspNetCore.Identity.SignInManager.ValidateSecurityStampAsync(ClaimsPrincipal principal) Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidateAsync(CookieValidatePrincipalContext context) Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync() Microsoft.AspNetCore.Authentication.AuthenticationHandler.AuthenticateAsync() Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, string scheme) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

尝试查询数据库时。关于为什么会这样的任何线索?

最佳答案

根据 comments 之一在博文中:

Thank you, this article was really useful. One gotcha for me was that after swapping to use an int when I first loaded identity server again I got an error on this line

Microsoft.AspNetCore.Identity.UserStoreBase.ConvertIdFromString(string id).

Turns out I had a cookie using the old guid format, simple fix was to clear cookies.

问题是您以前的一些登录可能是在 ID 是 GUID 时完成的。您将其更改为 int,因此现在它不再知道如何处理 GUID。最简单的解决方案是删除您的 cookie,有效地将您注销并强制您再次登录(改为使用 int)。

关于c# - 输入字符串的格式不正确 - 使用了错误的上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58340938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com