ASP.NET (OWIN) Identity: How to get UserID from a Web or API controller

Simple, reference that:

 

using Microsoft.AspNet.Identity;

 

After you can see two extensions:

//get User Id
var CurrentUserId = User.Identity.GetUserId()
//get UserName
var CurrentUserName = User.Identity.GetUserName()

Enjoy it!

Advertisements

One thought on “ASP.NET (OWIN) Identity: How to get UserID from a Web or API controller

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s