lzc
lzc

Reputation: 1705

How to reference the current user logged in MVC 4 EF

I want to know if getting the current user logged in, including ALL it's attributes to store in session (during login) would be a good idea.

SimpleMembership has been left pretty much stock. How I can call the user object to grab from the UserProfile table.

I didn't see the Login controller create a UserProfile object to store the current user. Is there any slick method with EF api to do this?

Upvotes: 0

Views: 337

Answers (2)

lzc
lzc

Reputation: 1705

This is how we can get a user object, and go through it's attributes

using (var ctx = new UsersContext())
{
     ctx.UserProfiles.Find(userID).ALL-ATTRIBUTES-HERE;
}

Upvotes: 0

Durgaprasad Budhwani
Durgaprasad Budhwani

Reputation: 977

using Microsoft.AspNet.Identity;

...

User.Identity.Name
User.Identity.IsAuthenticated

I think this will help you !!!!

Upvotes: 1

Related Questions