Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input string was not in a correct format error on using int keys

First i want to assure you that i have already read many posts with similar title on SO.

I have created an ASP.NET MVC project and changed the keys of template tables to int following this article

http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity

But i am getting a runtime error in this line of StartUp.Auth.cs

getUserIdCallback: (id) => (id.GetUserId<int>()))

Error = System.FormatException: Input string was not in a correct format. Any help is appreciated.

like image 278
It's a trap Avatar asked Mar 17 '16 12:03

It's a trap


People also ask

How do I fix resolve input string is not in a correct format error?

Input string was not in a correct format error occurs when you convert non-numeric data into an int or exceed the limit of the int data type. You should use Int. TryParse instead of Int32. Parse method to get rid of the said error.

What is input string?

String input templates allow you to specify the type, order, and number of characters a user can enter in a data entry field. You can define string input templates only on single‑line character data entry fields.

What is Input string was not in a correct format in Hindi?

कुछ ऐसा जो योग्य स्थिति में नही है ।


2 Answers

I know it's a late response. But for people who may encounter this in the future: Clear your cache or switch to a different browser.

Although you changed the pk from string to int in the code and updated Identity related tables, the cookie was still the one you logged in with string pks.

like image 107
Quentin Avatar answered Sep 28 '22 03:09

Quentin


To get rid of this error you need to clear cookies for your site.

Chrome: F12 -> Application -> Storage -> Cookies -> your site -> Clear

like image 42
sad_robot Avatar answered Sep 28 '22 02:09

sad_robot