After changing ASP.NET Core Identity to use int
rather than GUID (as per this blog post) I am receiving the following error:
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)
when trying to query the database. Any clues as to why that might be?
The input string was not in a correct format error might occur when you try to convert a non-numeric string from the input into an int. Moreover, you’ll get the said error while storing the input values that are larger than the range of the int data type as int.
An ‘input’ string refers to the data passed to a computer through a peripheral device such as a keyboard. A good example of this can be the data that you fill in the text boxes of an online form. – How To Ensure That the ‘Input’ String Matches a Particular Format?
When form initializes text box may not hae value if you have not put it in textbox when during form design. you can put int value in form design by setting text property in desgin and this should work. Share Follow answered Nov 30 '11 at 5:29
The given error occurs when you attempt to convert non-numeric data into an int. Also, exceeding the limit of the int data type to store larger values will give you the same error. Here are the detailed explanations of the causes: Are you working on a Windows Form and getting the above error?
As per one of the comments in the blog post:
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.
The issue is that some of your previous logins were likely done when the ID was a GUID. You changed it to int
, and so now it doesn't know how to handle the GUID any more. The simplest solution will be to delete your cookies, effectively logging you out and forcing you to login again (using int
instead).
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