1

I'm using forms authentication in my web application. Is there any way to logout (FormsAuthentication.SignOut;) using jQuery library or javascript?

1
  • Just think of ajax like any other page request, except it is done without a redirect or a hidden iframe. Commented Mar 4, 2011 at 2:17

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

By far the best answer here. Thank you for explaining it so elegantly.
1

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
});

Comments

0

Yes. You have to send an ajax request to the server. Look at ajax in the jquery documentation. http://api.jquery.com/jQuery.ajax/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.