How to use ASP.NET membership LoginStatus control

This simple control displays:

–  a login link if the user is not authenticated which automatically redirects to the configured login page

–  a logout link if the user is authenticated which automatically calls the method FormsAuthentication.SignOut

for logging off the user.

 

You can customize the LoginStatus control easily, because the control is fairly simple:

<asp:LoginStatus ID=”LoginStatus1″ runat=”server”

LoginText=”Sign In”

LogoutText=”Sign Out”

LogoutPageUrl=”./Default.aspx”

LogoutAction=”Redirect” />

The LoginStatus control offers a couple of properties for customizing the text shown for the links and the URLs to redirect to when the user clicks the link. You can find the most important properties in the next table:

 

Property

Description

LoginTextThe text displayed if the user is not signed in.
LoginImageUrlA URL for an image displayed as an icon for the login link.
LogoutTextThe text displayed if the user is authenticated.
LogoutImageUrlA URL for an image displayed as an icon for the logout link.
LogoutAction

Configures the action the control performs if the user clicks the logout link that isdisplayed when the user is authenticated. Valid options are:

– Refresh –refreshes the current page

– Redirect – redirects to the page configured in the LogoutPageUrl

– RedirectToLoginPage  – redirects to the login page