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

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

Hi,
      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
EventArgs)

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 .
Regards,
Rajesh
0
RAJESH SHARMA
Asked:
RAJESH SHARMA
1 Solution
 
HairyMikeCommented:
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.
0
 
chrsmrtnCommented:
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
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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