Reputation: 11
I'm using forms authentication in my web application. Is there any way to logout (FormsAuthentication.SignOut;) using jQuery library or javascript?
Upvotes: 1
Views: 4176
Reputation: 17955
Yes, you will need to create a controller action, if you're using MVC or a generic handler if you're using WebForms. This handler/action will need to call the FormsAuthentication.SignOut
method. In jQuery you will need to make an ajax call to this action/handler.
$.post('/url/of/signout/action', null, function(data) {
//handle successful logout
});
Upvotes: 1
Reputation: 42256
Yes. You have to send an ajax request to the server. Look at ajax in the jquery documentation. http://api.jquery.com/jQuery.ajax/
Upvotes: 0
Reputation: 490433
You could request that with XHR, except you will need to update your page to reflect the new state.
Upvotes: 2