How do you feel about the SQL table membership provider user?

When I create SQL tables and I want to access the ASP.NET membership provider user, what type of field am I using and how do I get the value from the user?

0


a source to share


1 answer


In SQL Server, you must use UNIQUEIDENTIFIER as the column type and map it to [dbo]. [aspnet_Users]. [UserId] . This assumes you are using the standard SqlMembership in an ASP.Net application. To get the logged in UserId in C # you should use:



MembershipUser mu = Membership.GetUser();  // This gets the CURRENTLY logged in user.
MembershipUser mu = Membership.GetUser("username");  // This gets the user with username username.
// Obviously you'd use only one of the above 2 lines, otherwise you'd get an error about mu being declared twice.
Guid currentUserId = (Guid)mu.ProviderUserKey;

      

+4


a source







All Articles