C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Browser close event


Posted Date: 04 Nov 2009      Posted By: Naveen      Member Level: Silver     Points: 1   Responses: 4



Hi guys,
i developed one web application using asp.net 2.0.
i need browser close event.
i restrict one user multi login... so they didn't click logout and close the browser means i need to close the session....

Regards,
Naveen





Responses

Author: Anuraj    04 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You can try window.unload event. It also fire on navigating from one page to another.

Thanks
Anuraj
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.
dotnetthoghts



Author: Deepak Yadav    04 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

Hi,
Naveen

For browser close event you may use the window.unload event, but for the user to give the facility of not giving multi login to a single user, for eg. like gmail, yahoo gives, you can create sessions for a particular user on the client side, on sign in for the first time make its value 1 and then keep it 1 until user logs out, or else clicking on logout make its value 0.
Cheers coding
Deepak



Author: ShashiKant Gupta    04 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

when user closes his browser, it doesn't sends anything to server where you can identify it close the session so I think you are going in wrong direction.

I will suggest you another approach.
create a table to maintain currently logged in users.
and at user's side use timer control with update panel to update this table with user's ID and current time.
this should be done each 5 or 10 mins as per requirement.

if user logs out or closes the browser window you can check it by checking the time against that user in your table, because time will stop being updated once the user logs out or closes his broser window.

hope this will help you.



Author: Naveen    13 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

hi ShashiKant Gupta,
Thanks for your kind reply.
i understand ur idea.. but u said

"closes the browser window you can check it by checking the time against that user in your table because time will stop being updated once the user logs out or closes his broser window."

at where to write these code or which page??

Regards,
Naveen.



Post Reply
You must Sign In to post a response.
Next : How to use style sheet in Master Page in .NET
Previous : Views in SQL and ASP.NET
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use