Reputation: 13
I'm working on a Employer-worker website. My problem is whenever a specific employer is log in I want to filter all the position that certain employer have and put it in a dropdown. How can I get the userId
of the current user for me be able to filter the position.
In the database of the employer I have a field named userId
it a FK of the userId
in my membershipId
table.
I found this on the net:
Guid userGuid = (Guid)Membership.GetUser().ProviderUserKey;
But I can't understand how can I use or put this on my controller.
Upvotes: 1
Views: 99
Reputation: 9947
Try this:
//simplified version
MembershipUser membershipUser = Membership.GetUser();
string UserID = membershipUser.ProviderUserKey.ToString();
The way you found is also correct, but the questions in where you want to use this in controller.
Most common uses are like redirecting the users to the corresponding view, which is accessible to the current user.
Upvotes: 1