How to maintain User Status on website in C# ASP.NET - Community Credit Forums
in

    Community Credit Forums

How to maintain User Status on website in C# ASP.NET

Last post 03-30-2008 4:24 AM by deepak kumarvasudevan. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-09-2008 1:32 AM

    How to maintain User Status on website in C# ASP.NET

    Hi All,

    I have one user authentication system on my site. Where a user can
    input his/her user name to check the updation of records. While login I
    am saving his/her online status (Like in any dating site)in a table
    called tblStatus. I am able to display their online status.
    I am also maintaing their offline stauts when they mannually click on
    logout button.
    My Problem:
    1)I want to display offline status if a user closes his/her browser.
    2)If there is any power failure. The status should become offline.
    My Question:
    1)Where should I update my tblstatus table to offline for that users.
    On What Event?

     

    Kindly help

    Filed under: ,
  • 02-09-2008 6:32 AM In reply to

    Re: How to maintain User Status on website in C# ASP.NET

    Great question!

    The main issue is that the HTTP protocol is stateless.  In other words, when a visitor makes a request, you handle it, and then forget they exist, until the next time they visit your site again.  This could be 20 minutes or 20 seconds, right.

    But, you do have some options.

    Each time visitor views a page, you could update your record to indicate the last time they visited the page.  The when you need to know who is online, adjust your query to list users who are logged in and who have last visited a page in the last 5 - 10 minutes.  You can adjust this.

    Of course, if they log out of your system this is not an issue.

    Depending on your site traffic, you may want to record user activity in memory or as an async process.

    As far as which event you can use, I would think the Application_BeginRequest or Application_EndRequest would work fine for recording activity.

    Here is a list of Global.asax events:  http://www.codetoad.com/asp.net_globalasax.asp

     

     

    Cheers,

    Karl

    Code Project MVP, Karl's Blog : Get Mole v4 Here also!

    Just a grain of sand on the worlds beaches.
  • 03-30-2008 4:24 AM In reply to

    Re: How to maintain User Status on website in C# ASP.NET

    Cookie or session can help you maintain the state. However, for extreme client-environment conditions like Power Failure, User closing the web browser you can work around the problem using a defined session timeout.

     

    ----
    Deepak K Vasudevan
    Architect
    http://deepakvasudevan.blogspot.com/
    http://www.lavanyadeepak.tk/
Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems