• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

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

      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 .
1 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.
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now