Feddy
Feddy

Reputation: 11

How to logout with jquery or just javascript using form authentication?

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

Answers (3)

Vadim
Vadim

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

smartcaveman
smartcaveman

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

alex
alex

Reputation: 490433

You could request that with XHR, except you will need to update your page to reflect the new state.

Upvotes: 2

Related Questions