0
I changed the PK of the Identity tables from string to Int, however when logging in Identity does not authenticate, log in normally but do not have access to any of the controllers that requires permission, go back to Home. I don’t know if it has anything to do with the problem Annotation of authorization of Managecontroller and debugged the Index action and the following line the result is always 0:
var userId = User.Identity.GetUserId<int>();
I wonder what it might be?
*If you need more information I will update the post.
GetUserId
is not an extension method? Edit your question and enter the method code. Probably the problem is there.– Jéf Bueno
Hello jbueno, it is the same Identity: public Static T Getuserid<T>(this Iidentity Identity) Where T : Iconvertible; I must extend it?
– Raphael
This may help. http://stackoverflow.com/questions/31705074/asp-net-identity-2-user-identity-getuseridint-always-returns-0
– Marco Souza
Thanks Goku, but had already seen this answer. And it seems that it is for Claims authentication and also do not know in which class should put this method.
– Raphael
Is there a reason to switch from string to int? the performance gains will be absolutely irrelevant! The method tries to catch an int (
Getuserid<int>()
) and the field in the bank is string... You would have to change that method too (and maybe others) to make that change. Honestly? I’d go back to PK for string and be happy.– Loudenvier
Thanks Loudenvier! , but if all tables use string one would make the performance lower? And also the other issue is that I wanted to show the code of some entities in the form, in case the user wants to search by code will be much easier to memorize a number than a code like Guid. And another is that the Urls would be more friendly, Example: meusite with/Product/Details/25 Regarding the bank I already changed string to int, but the problem still insists.
– Raphael