Back to VSLive! San Francisco Show Daily Home
Manage Users Fast
With ASP.NET 2.0
Add a new user to your system using ASP.NET 2.0's rich API for manipulating users and roles.
by Ken Getz
VSLive! San Francisco, February 8, 2005
Note: Ken Getz is presenting "Using the Time-Saving Membership Features in ASP.NET 2.0" at ASP Live! San Francisco, Tuesday, February 8. This tip is from that session.
ASP.NET 2.0 contains an amazing set of controls that enable you to provide standard Web-based authentication, user and role management, and more, without writing any code. But you don't have to use these controls. ASP.NET 2.0 also provides a rich API for manipulating users and roles, centered on the Membership, MembershipUser, and Roles classes.
For example, if you want to add a new user to your system, you could use the server control that handles this, or you could write code yourself, like this (assuming controls on a page matching the ones used here):
MembershipCreateStatus status;
Membership.CreateUser(txtUserName.Text,
txtPassword.Text, txtEmail.Text,
txtPasswordQuestion.Text, txtPasswordAnswer.Text,
true, out status);
lblStatus.Text = "Status = " + status.ToString();
These classes allow you to manage users and roles without needing to dig into the data storage layer—the pluggable provider model makes this all transparent in your applications.
About the Author
Ken Getz is a senior consultant with MCW Technologies and splits his time between programming, writing, and training. Ken has written many technical books, including ASP.NET Developer's Jumpstart with Paul D. Sheriff, and is coauthor of several best selling books, including the Access 2002 Developer's Handbooks and VBA Developer's Handbook.
Back to top
|