Intro to the Login Controls

When you begin to get exposed to the new features in ASP.NET 2.0 one of the first things you begin to familiarize yourself with is the new Login Controls.  They seem to be great and I will tell you about some of my experiences in several entries.

Here is a list of controls:

  • Login - complete user login control.
  • LoginView - Control what your user sees based on thier authentication.
  • Password Recovery - Let your absent minded users get their password.
  • Login Status - Nice way to let your user login and logout.
  • Login Name - Show your user you know who they are!
  • Create User Wizard - OK this one will not be simple to truely master, but we shall try.
  • Change Password - Good idea to let your users regularly change their password, that way they can use the Password Recovery Control!

I am not big on letting a standard control provide a one size fits all solution for me.  Meaning I am a little sceptical at this point about the Create User Wizard and Login Controls at this point, but I will give them a shot, later.

First let's start small.  The Login Status and Login Name controls can quickly be used by anyone, including myself.

The Login Status control is a great hyperlink control that will display 'Login' when you have an unathenticated user.  When clicked it will take your user to your login page (defined the web.config file).  So basically it requires some method of authentication to be defined for your site. 

Once your user is logged in it will display Logout and when clicked, logout the user and direct them to where every you want them to go.  You can control this with a combination of two attributes, LogoutAction and LogoutPageURL.  The LogoutAction property can be set to Refresh (default choice), Redirect and RedirecttoLoginPage.

Refresh simple reloads the current page for an anonymous user.  If the page is protected then you would go to the Login Page.  Redirect allows you to specify a page on your site, or anywhere on the Internet for that matter, you want your newly logouted user to see.  A praticle use is a page with a you have been logged out message.  That would be comforting to the user in this case.  RedirectToLoginPage will take the user to your login page.  Of course you can control the text displayed for login and logout, as well as your basic font choices, etc.

LoginName is what it says it is, simply the username for the user that is authenticated.  Sort of a nice feature.  It is basically a souped up Label with some extra attributes.  One that sticks out to me is the FormatString property.  It allows you to enter your own format like 'You are currently logged in as {0}'.  Kind of nice.

Good job on these controls.  I will certainly integrate them into my core site package from now own.  In my next Login Control Series entry I will cover the LoginView control.  This one looks good too.


Share This Article With Your Friends!