Working with Login, Roles and Profiles

I just spent a lot of time coming up to speed on Membership and how to hook it into SQL Server.  I wanted to capture some notes and links…


A good overview of the different pieces:

Information on how to configure membership so a help desk can reset/retrieve passwords:,guid,ea65afc0-2970-46f1-9412-4b57bbd906f4.aspx

ScottGu’s blog about adding Login, Roles, and Profile to ASP.NET 2.0 in only 24 lines of code:

By default, custom Profile fields are saved in the aspnet_Profile table in a property bag approach, with the names also having some metadata on them.  This doesn’t work well if you need to do queries against that data.  A better approach is to use the SQLTableProfileProvider available from the Microsoft Sandbox here:  Unfortunately the code has a lot of comments and possible “to do” items in it, but a lot people seem to be using it and it seems stable.  The downloaded code has SQLTableProfileProvider depending on SQLStoredProcedureProfileProvider, but those two functions can just be copied over (somebody got lazy and created a dependency).  Note that any table you create needs to have a

The tooling support in Visual Studio for Profiles only works for Web Sites, not Web Applications.  This means you can’t say Profile.MyField.  You can either create your own custom code for it or just call Profile.GetPropertyValue(“MyField”) and Profile.SetPropertyValue(“MyField”,”MyValue”) (look under “Converting Profile Object Code”)

Detailed tutorial about Membership, Roles, and Profile: