c# How to get the UserID of logged in user in mvc5

Add the name space in your controller at the top

 

using Microsoft.AspNet.Identity;

 

 

Wherever you need to get the user id use the following code in your controller

string userId = User.Identity.GetUserId();