Creating a Login Overlay
page 5 of 6
by Scott Mitchell
Feedback
Average Rating: 
Views (Total / Last 10 Days): 69869/ 151

Logging Users Off

In addition to the Sys.Services.AuthenticationService.login function, the MicrosoftAjaxApplicationServices.js script file includes a Sys.Services.AuthenticationService.logout function. Like the Sys.Services.AuthenticationService.login function, when calling the Sys.Services.AuthenticationService.logout function you can supply a redirectUrl parameter and callback functions to execute on success or failure.

In the downloadable demo, the master page displays a "Log Out" link in the upper right corner for logged in users. Clicking this "Log out" link executes the attemptLogout function, which calls the Sys.Services.AuthenticationService.logout function (see Listing 9).

Listing 9 - The attemptLogout function logs out the user.

function attemptLogout(redirectUrl) {
    Sys.Services.AuthenticationService.logout(
        redirectUrl,        // redirectUrl
        null,               // logoutCompletedCallback
        null,               // failedCallback
        null);              // userContext
}

As with the attemptLogin function, the attemptLogout function accepts a redirectUrl input parameter, which is passed into the Sys.Services.AuthenticationService.logout function's redirectUrl input parameter. The net effect is that if a redirectUrl input parameter value is supplied to the attemptLogout function then the user is redirected to the specified URL after successfully logging out. If this parameter value is not provided then the current page the user is visiting is reloaded after logging out.

When the "Log Out" link in the demo is clicked the attemptLogout function is called without specifying a redirectUrl input parameter. Consequently, the page the user is visiting when logging out is reloaded after log off. However, you could modify this script so that the user is redirected to a particular page upon log off.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-05 6:17:56 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search