Examining ASP.NET 2.0's Membership, Roles, and Profile - Part 5 07 Jun 2006 00:00 GMT| A Multipart Series on ASP.NET 2.0's Membership, Roles, and Profile |
|---|
This article is one in a series of articles on ASP.NET 2.0's membership, roles, and profile functionality.
|
Part 1 - learn about how the membership features
make providing user accounts on your website a breeze. This article covers the basics of membership, including why it is needed,
along with a look at the SqlMembershipProvider and the security Web controls.Part 2 - master how to create roles and
assign users to roles. This article shows how to setup roles, using role-based authorization, and displaying output on
a page depending upon the visitor's roles.Part 3 - see how to add the membership-related
schemas to an existing database using the ASP.NET SQL Server Registration Tool (aspnet_regsql.exe).Part 4 - improve the login experience by
showing more informative messages for users who log on with invalid credentials; also, see how to keep a log of invalid
login attempts.Part 5 - learn how to customize the Login control.
Adjust its appearance using properties and templates; customize the authentication logic to include a CAPTCHA.
(Subscribe to this Article Series!
)
ASP.NET 2.0 makes it quite easy to accomplish common tasks. Want to display data from a database, allowing the user to sort,
edit, delete, and page through that data? Simply add and configure a SqlDataSource on the page, bind it to a GridView, check
a few checkboxes in the GridView's smart tag, and, voila, you have a web-based data entry form that can be created in 15 minutes or
so. While the simple case is often a cinch to implement, in the real world rarely is the simple case a practical solution.
Often, the simple case needs to be extended and expanded and customized to fit custom rules, logic, formatting, and behavior.
Thankfully, ASP.NET 2.0 was designed with extensibility in mind and, thanks to things like the
provider model, event handlers, and templates, customizing
and extending the simple case is both doable and usually doable without an inordinate amount of effort or "hackery."
As we've seen throughout this article series, ASP.NET 2.0 provides a platform for creating and managing user accounts
through its membership, roles, and profile systems. The related Web controls - Login, LoginView, CreateUserWizard, LoginStatus, and so
on - can be used to achieve the simple case. Need to provide an interface for logging on a user? Simply drop the Login Web
control onto a page. But what if we want to customize the login experience? We may want to reposition the
Web controls used by the Login control or add additional content or Web controls to the Login control interface. Or we may want to
customize the credentials supplied by the user for authentication purposes. Rather than requiring just their username and
password, what if we want to also make them supply their email address on file? Or perhaps we want to include a
CAPTCHA (those boxes with text in an image designed to defeat robot
programs from successfully submitting a form).
The Login Web control can be customized in a number of ways. First, it has a bevy of properties that can adjust whether
or not the "Remember me next time" checkbox is displayed, the text displayed for the "Log In" Button, the colors, fonts, and
other style-related settings, and so on. For further control over the layout of the Login control or of the actual controls
that makeup the Login control, we can convert the control into a template. And finally, the control's authentication logic can
be customized by creating an event handler for the Authenticate event
(which can allow us, for example, to use a CAPTCHA as part of the authentication process).
In this article we'll examine how to customize the Login control through its properties, through templates, and by performing
custom authentication through an Authentication event handler (including an example with a CAPTCHA). Read on to learn more!
Read More >
Source: 4GuysFromRolla