I looked at binding my own user table to an asp.net membership, storing my userid (int) in the UserData area of the authentication cookie ( Storing and accessing an outdated UserID in the asp.net membership ).
As my application for my own use, and also to help me learn asp / C #, I thought it would be nice to compare the efforts to set up the membership so that it matches my database with the opposite (i.e. use membership from and edit my database accordingly).
If I convert my database to use UserAs guid (uniqueidentifier) identifiers as foreign keys in all tables associated with my users, then I still need a way to make UserID easily accessible for my application. The approved way to get the UserID looks like this:
Guid userID = (Guid)Membership.GetUser().ProviderUserKey;
Now, if I understand correctly, this is related to reading the database. I may be picky, but apparently this is a little superfluous for every request. I would be inclined to put it on the ticket. I see no problem putting the PK value on the ticket (guid or int). Is there a security risk? Membership seems happily using UserName as a key, not a surrogate. What begs the question - why didn't they put the UserID on the ticket?
source share