Get logged in user's id

asp.net-mvc-4, c#, simplemembership

Solution

I think you're looking for ProviderUserKey - Gets the user identifier from the membership data source for the user.

object id = Membership.GetUser().ProviderUserKey

Membership.GetUser() - Gets the information from the data source and updates the last-activity date/time stamp for the current logged-on membership user.

Problem

How can I get the logged in user's UserId? I'm using the standard system generated AccountModel. I can get the username using: ``` User.Identity.Name ``` but I don't see the UserId field. I want to use the UserId as a foreign key for another table.

Original source