MRainzo MRainzo - 5 months ago 18
ASP.NET (C#) Question

How to get the current logged in user Id ASP.NET MVC6

I've done this before with MVC5 using User.Identity.GetUserId() but that doesn't seem to work here.
The User.Identity doesnt have the GetUserId() method

I am using Microsoft.AspNet.Identity


I included using System.Security.Claims and I could access the GetUserId() extension method

NB: I had the using Microsoft.AspNet.Identity already but couldn't get the extension method. So I guess both of them have to be used in conjunction with one another

using Microsoft.AspNet.Identity;
using System.Security.Claims;