开发者

FormsAuthentication.SignOut() using javascript

开发者 https://www.devze.com 2023-01-30 05:31 出处:网络
Does anyone please help me for solving this issue, In my asp.net application, i am using FormsAuthentication.SignOut(); method for sign out the application, but i have one strange requirement that i h

Does anyone please help me for solving this issue, In my asp.net application, i am using FormsAuthentication.SignOut(); method for sign out the application, but i have one strange requirement that i have to implement the FormsAuthentication.SignOut() by using Javascript function. Is it possible? if yes, please help me by providing the sample code to achieving this requirement.开发者_Python百科

Thanks in advance


You can use AJAX to "load" the page that calls FormsAuthentication.SignOut.

Using JQuery it would look something like this, given that the logout button has ID "logout".

$('#logout').click(function () {
    $.ajax({
        url: '/logout',
        success: function () {
            document.location = '/logged_out';
        }, error: function () { 
            alert('Logout failed');
        }
    });
    return false;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消