When using membership provider, do you use the user ID or the username?

Posted by Chris on Programmers See other posts from Programmers or by Chris
Published on 2011-02-22T19:18:32Z Indexed on 2011/02/22 23:34 UTC
Read the original article Hit count: 318

I've come across this is in a couple of different applications that I've worked on. They all used the ASP.NET Membership Provider for user accounts and controlling access to certain areas, but when we've gotten down into the code I've noticed that in one we're passing around the string based user name, like "Ralph Waters", or we're passing around the Guid based user ID from the membership table.

Now both seem to work. You can make methods which get by username, or get by user ID, but both have felt somewhat "funny". When you pass a string like "Ralph Waters" you're passing essentially two separate words that make up a unique identifier. And with a Guid, you're passing around a string/number combination which can be cast and made unique.

So my question is this; when using Membership Provider, which do you use, the username or the user ID to get back to the user?

Thanks all!

© Programmers or respective owner

Related posts about architecture

Related posts about ASP.NET