ASP.Net 3.5: User Account Creation for Your Website

If you're setting up an ASP.NET website that will have a membership of registered users, such as a forum or some kinds of blogs, you want to make the registration as simple as possible. This article will show you how to set up a website that allows users to create their own accounts, without involving the administrator.

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 22
July 21, 2010
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

You may have read our article on "ASP.NET 3.5 Basic User Account Management," which is an introductory tutorial on how to enable ASP.NET 3.5 Membership to start registering and managing users for your website.

In that tutorial, we used the "Website Administration Tool" for registering new users of the website. This means that only the website administrator/developer can register new users.

However, in real world applications of ASP.NET 3.5 websites found on the Internet, website visitors can create their own new ASP.NET 3.5 account.

These sites use an ASP.NET web page to register new users and not the "Website Administration Tool," which can only be used by an administrator.

This tutorial will focus on the development of ASP.NET 3.5 websites that allow users to create their own accounts. It is highly recommended that you read the first tutorial, so that you will have an in-depth understanding of the ASP.NET 3.5 membership system.

"CreateUserWizard" Tool in Visual Web Developer

Since the .NET technology in developing websites is as simple as using the "click and drag" method (with no need to hard code everything), the same thing applies to creating web pages that can accept users registration.

If you have Visual Web Developer Express 2008 installed, go to View -> Toolbox -> Login. You should see the CreateUserWizard web control.

To illustrate how to use this web control for accepting new users to your website, follow the steps below:

Step 1: Launch Visual Web Developer Express.

Step 2: Create new ASP.NET website and name that project CreateNewUser; click OK.

Step 3: Once the Default.aspx source code has been shown in Visual Web Developer, click and drag the CreateUserWizard web control (View -> Toolbox -> Login -> CreateUserWizard) to between the <form><div> ... </div></form> tags in the Default.aspx source code.

Step 4: Go to File -> Save All.

Step 5: Go to File -> View in Browser. You should see the default output of the CreateUserWizard web control, and it should look like the screen shot shown below:

You will notice that this is the same information asked for when you create users using the "Website Administration Tool" discussed in the previous tutorial, "ASP.NET 3.5 Basic User Account Management."

Signing up as a New User with the Default Registration Form

Try signing up using the default user registration form shown in a web browser. You need to enter all fields as completely as possible, and then click "Create User."

Below is the screen shot of this process:

You will notice that if you click "Continue," it won't take you to another page. This is because you still need to set the "success" URL after any successful user registration.

This success URL can be controlled using the "ContinueDestinationPageUrl" property of CreateUserWizard web control.

Try creating a new ASP.NET page for your success URL and name it  ThankYou.aspx. Follow the rest of the steps below:

Step 1: Go to File -> New File.

Step 2: Under "Visual Studio installed templates," click "Web form."

Step  3: Under name, change Default2.aspx to ThankYou.aspx

Step 4: Set Language to Visual Basic, check "Place code in separate file" and uncheck "Select master page."

Step 5: Finally, click the "Add" button.

Step 6: Go to File -> Save All.

Step 7: Double click ThankYou.aspx under Solution Explorer.

Step 8: Let's add a thank you message for the newly-registered user, as shown below:

%@ Page Language="VB" AutoEventWireup="false" CodeFile="ThankYou.aspx.vb" Inherits="ThankYou" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

Thank you for registering as new user of our website!

</div>

</form>

</body>

</html>

Then go to File -> Save all.

Completing the Thank You message

Step 9: Close ThankYou.aspx and go to the design view of the Default.aspx. What you see should match the screen shot below:

The one you will see is the CreateUserWizard web control.

Step 10. Click the CreateUserWizard web control, and you should see the CreateUserWizard1 properties shown in the lower left portion of Visual Web Developer.

Step 11. Under the properties window of CreateuserWizard, go to "Behavior" and you should see the ContinueDestinationPageUrl. Click it, and you should see an ellipsis (screen shot shown below).

Step 12. Clicking the ellipsis will open the "Select URL" window.

Step 13. Select ThankYou.aspx and click OK.

 

Step 14. Go to File -> Save all.

Try viewing the user registration again on the browser by going to File -> View in Browser.

Try to test to see if the continue page will work by registering another user; then, click "Create User" and finally click the "Continue" button. You should now be seeing the Thank you page.

Important note: ASP.NET 3.5 will automatically create a new MS SQL server database named ASPNETDB.MDF after the first user of the website is registered.

You can find this database under the App_Data folder. To avoid hosting deployment complexities and issues, it is best to use this database for both your user account management and website application data.

Sending email after user registration

It is also possible to send an email after user registration, which is commonly done by most ASP.NET websites. To do this you should have the following two requirements in place before you can enable this feature: first, a fully working SMTP email server; and second, a configuration for your website that allows it to send email (SMTP configuration in the Website Administration Tool).

Details of the configuration and troubleshooting of your website email function is out of the scope of this article, and will be discussed in a separate tutorial.  However, the most basic steps are as follows:

1. In Visual Web Developer, go to Website -> ASP.NET configuration.

2. The ASP.NET web application administration will then be launched in the browser.

3. Click "Application Configuration."

4. Click "Configure SMTP e-mail settings."

5. Assuming you have working a SMTP settings, fill in the details provided here by your SMTP server. Depending on the SMTP server, you will select either NONE, Basic or NTLM authentications.

In most cases, you will select the "Basic" authentication because the SMTP server will require a username and a password.

6. Click Save.

7. Finally, Click OK.

Now that you have configured SMTP for your website, you need to enable email features in the user registration process in the CreateUserWizard web control.

Step 1. Go to the properties window of the CreateUserWizard web control in the design view.

Step 2. You need to go to the MailDefinition property and configure the settings to look like what is shown in the screen shot below:

You need to fill in these details as accurately as possible (as shown in the screen shot). By the way, /App_Data/emailtemplate.txt is the email template body.

You can choose to send the mail as either a text or an HTML. For example, the following is the content of the email in text (content of emailtemplate.txt):

Hi <%UserName%>!

Congratulations, you have just created a new user account with our website. Any questions send me an mail at codex_m@yahoo.com

Sincerely,

Codex

Note that the username will be outputted to the email body using a placeholder: <%UserName%>. You can likewise do the same to output a password in the mail <%Password%>, but this is not recommended if you are sending emails unencrypted through the Internet (due to the risk of eavesdropping). However, if your SMTP server supports encryption (such as SSL), then you can send sensitive information like passwords without the risk of eavesdropping.

In the upcoming tutorials, you will learn how to add a login page in your ASP.NET website where registered users can start logging in to access your website's contents. Combined with the "roles" feature, which is discussed in yesterday's tutorial, you can restrict registered users by putting access limitations on the website content. (For example, you will want to limit access to certain files to administrators).

blog comments powered by Disqus
ASP.NET ARTICLES

- Implementing ASP.NET 4.0 Page.MetaDescriptio...
- ASP.Net Development Tips
- Intro to Sessions in ASP.Net
- Google Maps API Introduction in ASP.NET usin...
- Creating an ASP.NET 3.5 Gridview Image Galle...
- Encrypt QueryString in ASP.NET 3.5 using VB....
- ASP.NET 3.5 Drop Down List Controls
- Connect to Access Database with ASP.Net
- Secure Audio Streaming with ASP.Net and Flash
- Dynamic Sitemap and Navigation in ASP.Net
- Implement Gzip and Deflate Compression in AS...
- Run ASP.Net in Ubuntu with Apache
- ASP.Net Mono Website Contact Forms
- ASP.Net URL Rewriting Methods
- Murach`s ASP.NET 4 Web Programming with C# 2...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials