Preparing a Site for Membership
To create a new ASP.NET Web site
- Start Visual Studio or Visual Web Developer.
- In the File menu, click New Web Site. (If you do not see this option, click New, and then click Web Site.)
- The New Web Site dialog box is displayed.
- Under Installed Templates, click Visual Basic or C# and then select ASP.NET Web Site.
- In the Web Location box, select File System and enter the name of the folder where you want to keep the pages of the Web site. For example, enter the folder name C:\Websites\Login and then click OK.
- Visual Studio creates the folder and opens the Web site in Source view. Notice that the root Web site contains several files and folders including the Account folder, a Web.config file, the About.aspx and Default.aspx pages, and the Site.master master page.
- Press CTRL+F5 to run the page.
- The home of page of the Web site is displayed in the browser. Notice the menu items (Home, About) and the Log In hyperlink.
- Close the browser.
To create the members only page
- In Solution Explorer, right click the Account folder and then click Add New Item.
- In the New Web Sites dialog box, select Web Form.
- In the Name text box, enter MembersOnly.aspx.
- Select the Select master page check box and then click Add.
- The Select a Master Page dialog box is displayed.
- Under Contents of folders, select Site.master and then click OK.
- The MembersOnly.aspx page is created in the Account folder. The page is a content page for the Site.master page.
- In Solution Explorer, double-click the MemberOnly.aspx page to open it, and then switch to Design view.
- Add content to the main page. For example, you can add “Welcome to the members-only page. You have successfully logged in.”
In addition to the page that you have created, the Account folder contains the following pages and files:
- Register.aspx. This page lets new users create an account.
- Login.aspx page. This asks for a user name and password.
- ChangePassword.aspx. This page lets registered users change their password.
- ChangePasswordSuccess.aspx. This page is displayed when users successfully change their password.
- A Web.config file.
By default, pages in the Account folder are not accessible to anonymous users, except the Register.aspx and the Login.aspx pages. The settings that define access to pages in the Account folder are configured in the Web.config file in that folder. The settings that define access to the Login page is configured in the root Web.config file.