I am using Asp.Net/C# in my project.I am using Forms Authentication.Currently I call FormsAuthentication.SignOut() on click of Asp.Net button.It works well , but my requirement is that I need to log out a user from horizontal menu option
Logout
That would be Html menu , so how do I call FormsAuthentication.SignOut() method when a user clicks Logout from the menu bar.Is there any solution possible or any other technique.
Any suggestions are welcome.
Thanks
FormsAuthentication.SignOut()is a server side code and you cannot directly invoke it from client side (i.e. browser) – instead, you need to create a URI that will do the same for you.For example, you can have AJAX service that will call above code or simply speaking, you can have logout.aspx page that will call
FormsAuthentication.SignOut()in saypage_load. Such a URI can be invoked from jquery to get you what you want.In your case, you should simply have a link to logout aspx page in your logout menu (or in menu click, write
document.location = "/logout.aspx"which essentially means navigating to log-out page).