Setting Up the Login User Interface
VWD ships with several Login controls that encapsulate
authentication and identification security functionality. In this lesson you will set up Web pages with several of these Login controls.
First, in order to authenticate a user you need a login form. For this you will
use the new Login control, which conveniently creates a configurable login interface
by merely draging it from the Toolbox onto the design surface.
It's always a good idea to provide feedback to the user about their authentication
status. The new LoginStatus control provides this. A nice feature of this control
is that it provides a link for logging in or out, depending upon whether the user
is anonymous or authenticated.
Finally, you probably have often needed to display information and controls to users
who are not logged in that is different from information and controls for users
who are logged in. The new LoginView
control makes implementing this functionality much easier. As its name implies,
a different "view" of the page content is displayed to the user depending upon whether
they are anonymous or authenticated. In a way, the LoginView control is like a security-aware
You begin by creating a secure area for
1. In the Solution Explorer, right-click the project and select
New Folder. New this new folder "Admin".
You will not secure this folder until the next lesson.
2. Right-click the Admin folder and select Add New Item.
Add a new Web Form called "default.aspx". You do not need a separate code file or
a master page, so uncheck both options, and then click Add. Type
some text to the page, such as "This is my secure Web page".
3. To the web.sitemap file add another child siteMapNode
to display a link to "Administration" url="~\Admin\default.aspx".
4. Add a new Web Form to the root of your project, naming it "login.aspx".
Check Place code in separate file, but leave Select master
5. Click Design. From the Login section of the
Toolbox, drag a Login control onto the design
6. In the Login Tasks menu click Auto Format
and select a color scheme of your choice. Press F4 to access the Login control's
properties, changing the ID to "adminLogin". Also change the
DestinationPageUrl property to "~/authors.aspx" so that when the user
logs in they are taken directly to this page. (If this property is not set you are
redirected to default.aspx.)
7. Open the Master Page in Design view.
Create a line break after the "Authors" header. From the Toolbox,
drag a LoginView control to the design surface, placing it beneath the "Authors" header.
8. In the LoginView Tasks menu, for Views
ensure that AnonymousTemplate is selected. Press ESC
to close the menu and then enter some text into the white area below "LoginView1",
such as "You are not logged in".
9. Open the LoginView Tasks menu and for Views
select LoggedInTemplate. As before, enter text such as "You are
currently logged in". Then, as with the Login control, change its
ID property to "adminLoginView".
10. From the Toolbox drag a LoginStatus control ontop the design surface, placing it next to the LoginView
control. Change its ID property to "adminLoginStatus". Place your
cursor after the LoginStatus control and press Enter
to create some white space for better presentation.
There is nothing additional you need to configure for the LoginStatus control. It's
built-in Login link points to login.aspx by default. With your security interface
built, you are now ready to configure the Web site's security via the Web Administration