ASP.Net 2.0 LoginStatus Control
LoginStatus control also works with sql membership provider of asp.net 2.0 that detects the status of user currently logged in or not. If user is currently logged in then LoginStatus control displays the logout button and if the user has not logged in the web site or the user is viewing the page anonymously then LoginStatus Control displays the login button.
Login button of LoginStatus control sends the user to the login page. LoginStatus control picks the path of the login page from the forms authentication section of the web.config file e.g.:
<authentication mode="Forms"> <forms loginUrl="~/login.aspx" name=".SECUREAUTH"> </forms> </authentication>
Logout button logouts the user and refreshes the current web page and changes the Login Status of current user by resetting the LoginStatus Control to display login button again.
You can also change the logout page destination by setting LoginStatus Control properties as following:
LogoutAction property consists of 3 values:
Refresh: refreshes the current web page when user clicks on logout button.
Redirect: redirects the user to the page specified in the LogoutPageUrl property if LoginStatus Control
RedirectToLoginPage: redirects to the login page specified in the Forms authentication section of web.config file as discussed above.
LogoutPageUrl property accepts the URL to which it redirects the user when he clicks on logout button.
Continue to next tutorial: ASP.Net 2.0 LoginView Control to learn how to display the contents or options based on logged user role.