How to Get the Current Logged in User Id in ASP.NET Identity

How to Get the Current Logged-in User Id in ASP.NET Identity

Once the user logs in, then in order to get the Id of the currently logged-in user in ASP.NET Identity, we need to use the GetUserId method.

GetUserId

The GetUserId method returns the user id for the current HTTP request. The syntax to use the GetUserId() method is as follows:

string userId = User.Identity.GetUserId();

Namespace: In order to use the GetUserId method, you have to include the following namespace:

using Microsoft.AspNet.Identity;

In the next article, I am going to discuss How to Logout a User in ASP.NET Identity. Here, in this article, I try to explain How to Get the Current Logged in User Id in ASP.NET Identity. I hope you enjoy this article.

1 thought on “How to Get the Current Logged in User Id in ASP.NET Identity”

Leave a Reply

Your email address will not be published. Required fields are marked *