How To Create Membership and Login Controls in ASP.Net

Your website might be one that invites visitors to become members so they can get special discounts on products or be able to view private documents. To sign up these visitors and turn them into members, your website will need to have membership forms to gather basic information from the visitors and enable them to enter a username and a password to login on the website. The site will have certain pages that cannot be accessed unless you sign up and become a member. The membership and login controls can be created in, using very few codes.

  1. Creating a membership page - Select the configuration and click the security tab and select the security setup wizard. Follow the instructions for configuring security then when you click next, select the Internet option. This option will enable users on the Internet to access the membership forms and login from the web. You have to specify now what sort of role the user will use. This is just like a designation to separate members who will only have access to certain pages and they will only be limited to viewing and not to edit portions of the page. Create a new user on the next page of the wizard; this is where you enter information like your user name, password, your email, a security question and answer. The create user button needs to be clicked. You will get a confirmation notification. The next part of the configuration defines the rules for accessing the MemberPages folders. In the Add New Access Rule Box, choose the MemberPages Folder then click the Anonymous users and click the Deny option for permission, then select Add this Rule and Finish. This will deny non members access to the pages that are exclusive for members only.
  2. Creating the login page - In the Solution Explorer window add a web form and name it Login.aspx by right clicking Web Application and then choose the Add new item option. Drag and drop Login from the toolbar to the work area. This is the field where members login their username and password to gain access to the site. You will now create a welcome message to greet members who login and a message for users who are not logged in. Drag and drop the Loginview control to the page and click the little arrow button to edit the AnonymousTemplate by typing in "Click Link to Login." For the message that greets logged in users we go to the LoginView Tasks Panel then select the LogInTemplate. Select the edit area of LoginView then type in "You are successfully logged in. Welcome," and then drag LoginName in the template from the toolbar after Welcome.

Membership forms and login fields provide security to your website and the data it provides its members. Creating these functions in for your website is easy and uses very little coding.


Share this article!

Follow us!

Find more helpful articles: