Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once you have created a login page and run it for the first time, resulting in creating the authentication database, you can then start adding users. Once again, there is a component in the ASP.NET 3.5 Framework for this purpose. For this demonstration, I'll use the file Signup.aspx. I'll open the file and then take a look at it in Design view. Notice that once again it's an empty page with just a banner graphic at the top and a paragraph. Next, I'll go to the Toolbox to the Login section and I'll select the component CreateUserWizard. And I'll drag the component and place it in the page.
The CreateUserWizard component includes fields for user name, password, email and a security question and answer. And it requires that the user type in the password twice. By default, it requires a password that's at least seven characters long and includes one non- alphanumeric character, such as a pound sign, an ampersand or something else that's not a letter or a number. Also, in the ASP.NET 3.5 authentication model, the password is case sensitive. You can choose how to communicate all of this to your user. Once I have dropped the component in, I'll then format it, I'll go to the task list and select Auto Format and I'll choose the same Auto Format option that I used for the Login form, Simple. And I'll click OK.
Now, the two pages have a similar look and feel. I'll save the changes to that file and then I'll go back to the Login form and I'll select the Login component. The Login component has a way of creating a link automatically to your signup page. With the Login component selected, I'll go to the Properties panel and double click its header to make it float and then expand it. Then I'll add two properties that the user can use to get from the login form to the signup form. I'll go to the property CreateUserText and I'll type in the text, Register as a new user. Notice that after I type in that text and press the Tab key, the text I typed in appears in the Login form in the Design view.
Next, I'll go to the property CreateUserURL. This is how you designate the page you want the user to go to if they click the link. I'll click into the property and then click the Browse button that appears and I'll select the file Signup.aspx and click OK. I'll save my changes and then run the page selecting Debug > Start Without Debugging. When the Login form appears, I'll click onto the Register as a new user icon and that takes me to the Signup form.
I will click into the form and type in a username of newuser. Then I'll enter a password twice, remember that the password must be at least seven characters and include a non-alphanumeric character. Make sure you type the password exactly the same both the times. Then type in an e-mail address, type in a Security Question and a Security Answer. The login system has the ability to prompt the user for the security question and then allow them to get back into their account later. I'll click Create User and when the form completes its operation, the newuser information will have been added to the authentication database. The Continue button currently only goes back to the current page, but now I'll go back and run the Login form again.
I will just go up to the web browser URL and go to Login.aspx. I'll type in the username and password that I created, newuser and the user password. I'll click the Log In button and I'm taken automatically to the homepage of the website. So, now I have created two of the most critical components for an authentication system, a Login form and a way to add new users. In other videos in this chapter, I'll describe the structure of the database that contains the authentication information and then describe how to lock down the website, so when a user tries to navigate to various pages of the website, they are automatically taken to the Login form.
Get unlimited access to all courses for just $25/month.Become a member