Wednesday, August 28, 2013

How to Store Logout information when browser tab closed using asp.net c#.net and javascript

Logout_TabClosed
In this article, i would like to explain "How to Store Logout information when browser tab closed using asp.net c#.net and javascript".So many requests we are receving from beginners.I hope it will helps for them.
I have checked in all browsers its working fine.I have already shared Some articles related to this.


How to create a login page in Aspnet with sqlserver

How to create a LOGOUT Page using Sessions

A journey from Login Page to Logout Page in Asp.net  

Now, "How to Store Logout information when browser tab closed using asp.net c#.net and javascript"

Let's Start: 

First Step : Write the following simple script to call logout button event
 
When you close the tab, beforeunload script function will be fire and then it calls necessary button event 

In Next Step:
Write the necessary code in button Event

protected void btnLogout_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Session.Remove("Username");        
        //Save the Necessary logout information in Database.
        Response.Redirect("Home.aspx");
    }

That's it.I hope it will helps.

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home