How to add a Login, Roles and Profile system to an ASP.NET 2.0 app in only 24 lines of code
page 1 of 7
Published: 18 Oct 2005
Unedited - Community Contributed
Abstract
In this article, Scott explore how to add a login, roles and profile system to an ASP.NET 2.0 application with the help of code samples.
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 57783/ 104

Introduction

Republished With Permission - Original Article

I’ve seen a few questions in the forums lately looking for examples on how to use the CreateUserWizard control to create new users in the ASP.NET 2.0 membership system, and then as part of the registration process assign the new user into custom roles and/or collect and store custom profile properties about them (country, address, gender, zipcode, etc).

Stefan from my team had a cool CreateUserWizard control sample that I borrowed and expanded upon to build-up a sample that demonstrates how to build a fairly common user management, roles and personalization system in ASP.NET 2.0 that does this.  I was pleasantly surprised to find it only took about 25 lines of C# code in the entire app. J

The sample comes with 6 pages:

Figure 1

Specifically it supports:

1) Login support to enable registered users to login to the web app using forms auth and the new membership system (login.aspx)

2) Registration support to enable visitors to create and register new users in the membership system (CreateNewWizard.aspx)

3) Profile support that enables the site to gather information about the user on registration, and for the users to see that information on a profile page (MyProfile.aspx). 

4) Change Password support to enable registered users to change their password in the membership system (ChangePassword.aspx)

5) Password Recovery support to enable users to reset their password if they forgot them (RecoverPassword.aspx)

You can download and run the sample yourself from here.  Note that it is built with the final release of VS 2005 and ASP.NET 2.0 – so it won’t work with Beta2 (although it will probably work with the RC).


View Entire Article

User Comments

Title: Thanks for the TRICK   
Name: Ankit Singhal
Date: 12/20/2009 3:05:23 PM
Comment:
Thanks a lot for such a wonderful idea.. it worked for me when used CreatedUser and FinishButtonClick Events in place of the Events u suggested. Great Idea. God Bless you :-)
Title: problem!!!!!   
Name: avinash
Date: 4/7/2008 4:01:15 AM
Comment:
this code works fine with me in a public authorization folder! i need this code to make only role "admin" can create accounts so i placed it in a folder with admins only authorized! but the problem is that t creates the account but don't assign any role!! can any body help with this ?
Title: Roles   
Name: Hossam
Date: 7/11/2007 3:47:45 AM
Comment:
this code works fine with me in a public authorization folder! i need this code to make only role "admin" can create accounts so i placed it in a folder with admins only authorized! but the problem is that t creates the account but don't assign any role!! can any body help with this ?
Title: next step   
Name: dupls
Date: 3/21/2007 1:29:34 PM
Comment:
Is there any tutorial out there that will take this to the next level and place those details into another table in the database?

I've followed Scott through a zillion sites he is truly amazing. Very helpful code!
Title: Ruler of the Universe   
Name: Rick
Date: 3/8/2007 7:39:47 PM
Comment:
Not too many comments here, but I think this is a fantastic soution. Thank you for sharing with us, Scott.
Title: Mr   
Name: Pilling
Date: 11/14/2006 11:17:50 AM
Comment:
Anyone have the rolls bit in vb?

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 10/20/2014 8:32:29 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search