How to maintain webpage hit and user’s credential through global.asax in

Posted on 2006-05-10
Last Modified: 2010-08-05
      I am developing web base application; it contains more than 75 WebPages. Basically, in my application there are 20 users log in and access the pages. Now I would like to track or store information about user in the database i.e history of login time, logout time and total number of hit WebPages by users. Let us assume user1 logs in and accesses the page1 and page 2 five times then I will store in the database. User id , login time, page name and no of Hit for each and every page hit by particular user. Actually I have an idea like when page first time loads i.e post back property is false then I insert or update in the database. It works well. But there are 75 web pages and its complex task to write code on each and every page Actually I don’t write the same code on all pages. I got an idea this can be done in global. asax. I wrote code on this event in global.asax
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As

End Sub

In this event I am not able to maintain user’s name Can I maintain User SessionID in
Application_BeginRequest in global. asax. Please let me know alternative way to handle this problem.

Any Help is appreciated .
    LVL 1

    Accepted Solution

    Note that the global.asax file must be in the root of the directory / virtual directory for it to work properly.

    In regard to sessions..  Are you maintaining your user's credentials through session variables?  If so, just set them all in the session_start routine.
    LVL 2

    Expert Comment

    Well i'd store the tracking information in session variables throughout the site.  I'd place the tracking counters code in a globally accessible file, so i only have to make one change to update the tracking code.  

    I'd create a Tracking class that will handle all of my tracking calculations.  Keep in mind that in the tracking class save the updated values to the session variables.  

    Then in the global.asax i'd put the "save compiled stats" code in the application unload sub.  That way when they cleanly leave the site, we can save off their stats before they go ;)

     Now of course this is a web appllication, so tracking a client termination (like they suddenly powered off) is tricky.  I'd suggest including a update mechanism in the tracking class to automatically write the statistics every 5 calls into the tracking class.  That way you can even collect some information before the client possible terminates their connection unexpectedly

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    hasOne  challenge 59 64
    dividesSelf challange 15 60
    factorial example challenge 10 44
    triangle challenge 4 38
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    A short article about problems I had with the new location API and permissions in Marshmallow
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now