I am using Asp.net Identity 2 in my application. I get the current user Id like this:
User.Identity.GetUserId()
It works fine, but when I login to my dashboard, and then create the user from dashboard like this:
User.Identity.GetUserId()
The id is replaced with inserted user.
How can I solve this issue?
If you are using an implementation like the default AccountController::Register
, note that this action signs in the new user after the registration, i.e.:
await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
You should be fine by removing that line in your implementation.