Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.Services AuthenticationService logout Method

Logs out the currently authenticated user.

Syntax

Sys.Services.AuthenticationService.logout(redirectUrl, logoutCompletedCallback, failedCallback, userContext);

Parameter

Description

redirectUrl

The URL to redirect the browser to on successful logout. The default is null.

logoutCompletedCallback

The function that is called when the logout has finished. The default is null.

failedCallback

The function that is called if the logout has failed. The default is null.

userContext

User context information that you are passing to the callback functions.

Remarks

If redirectUrl is null or is an empty string, the page is redirected to itself after the call to the authentication Web service finishes and the completed callback function is called. This makes sure that any user-related data is cleared from the page.

If redirectUrl is not null or is a non-empty string, the page is redirected to the specified URL after a successful call to the Web service. This URL can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path.

If the call to the Web service fails, the page is not redirected or refreshed. Instead, the failed callback function is called.

Example

The following example shows how to use the logout method to check the user's credentials. This code is part of a complete example found in the Sys.Services.AuthenticationService class overview.

javascript

// This function calls the logout method of the
// authentication service to clear the forms 
// authentication cookie.
function OnClickLogout() 
{  
   // Clear the forms authentication cookie. 
   Sys.Services.AuthenticationService.logout(null, 
        null, null, null); 
}