Personalization Using Visual Basic 2005 - Creating Accounts Programatically
(Page 3 of 6 )
Your initial goal is to have two pages: a default page that displays different information depending on whether users are logged in or not, and a login page that allows the user to log in.
To have users log in, however, you must first create accounts. Create a new page called CreateAccount.aspx. (Right-click on the application and choose Add New Item. Choose web form and set the name to CreateAccount.aspx).
Click on the Design tab for your page, and then click on the Login tab in the Toolbox. Drag an instance ofCreateUserWizardonto your page, as shown in Figure 12-7.

Figure 12-7. CreateUserWizard
TheCreateUserWizardprompts the user for a username, a password (twice), an email address, and a security question and answer. All of this is configurable through the HTML that is created by this control; through the Properties window; or, more commonly, through the smart tag, as shown in Figure 12-8.

Figure 12-8. CreateUserWizard tasks
Click on the control and scroll through the properties to find theContinueDestinationPageURL. Click the ellipses (...) button and choose the Create Account page itself (CreateAccount.aspx), so that you’ll be brought back to the same page after the new user is confirmed. Click on the Document and scroll down the Properties window to the title of the page to Create User. Finally, set the CreateAccount.aspx page as your Start page, and fire up the application.
Assuming you created this application, using the WAT as described earlier, you will be prompted to create a Web.config file. Click OK to add the new Web.config file with debugging enabled.
When the page opens, you will be prompted to add a new user, as shown in Figure 12-9.

Figure 12-9. Testing CreateAccountWizard
Remember to use a strong password, as explained earlier.
When you click Create User, the account is created, and you are brought to a confirmation screen. Click Continue, and you are brought back to the Create Account screen to create a second account. Add a couple of accounts, then stop the application and examine your database.
To see the profile database, click on ServerExplorer and make a connection to <machine>\sqlexpress.aspnetdb.dbo.
You should find that a database named aspnetdb with many tables, including theaspnet_Userstable. You can display it by right-clicking and choosing Show Table Data, as shown in Figure 12-10.

Figure 12-10. Personalization database updated
Next: Creating the Welcome Page >>
More Visual Basic.NET Articles
More By O'Reilly Media
|
This article is excerpted from chapter 12 of the book Programming Visual Basic 2005, written by Jesse Liberty (O'Reilly, 2005; ISBN: 0596009496). Check it out today at your favorite bookstore. Buy this book now.
|
|