In order to get CurrentUserId in Asp.net Identity 2.0, at first import Microsoft.AspNet.Identity
:
C#:
using Microsoft.AspNet.Identity;
VB.NET:
Imports Microsoft.AspNet.Identity
And then call User.Identity.GetUserId()
everywhere you want:
strCurrentUserId = User.Identity.GetUserId()
This method returns current user id as defined datatype for userid in database (the default is String
).