O'Reilly logo

ASP.NET 2.0 Website Programming Problem - Design - Solution by Marco Bellinaso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.3. Solution

We'll get right into the implementation because we've already covered the basic material and our objectives in the "Design" section of this chapter. Now we'll put all the pieces together to create the pages and the supporting code to make them work. These are the steps used to tackle our solution:

  1. Define all the settings required for membership, roles, and profiles in web.config.

  2. Create the login box on the master page, and the "access denied" page. To test the login process before creating the registration page, we can easily create a user account from the ASP.NET Web Administration Tool.

  3. Create the registration and profiling page.

  4. Create the password recovery page.

  5. Create the page to change the current password and all the profile information.

  6. Design profiles to save the user's favorite theme, and handle the migration from an anonymous user to an authenticated user so we won't lose his theme preference.

  7. Create the administration pages to display all users, as well as edit and delete them.

4.3.1. The Configuration File

Following is a partial snippet of the web.config file (located in the site's root folder) used to configure the authentication type, membership, role manager, profile, and sitemap provider (in this order):

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <!-- other settings... --> <system.web> <authentication mode="Forms"> <forms cookieless="AutoDetect" loginUrl="~/AccessDenied.aspx" name="TBHFORMAUTH" /> </authentication> <membership ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required