473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Tracking Visitors in asp.net

Hello all,
I am working on asp.net 2.0 , i want to track the visitor , actually i want to log the visitor information in a text file. I want the amount of time for which user is stay on a particular page. All my pages are static meanse there is no sign in and sign out concept , user can view page directly i just want to log for how much time a user is stay on that page.

Please give me some idea .
Thakns
Rohit vyas
May 20 '08 #1
6 1926
DrBunchman
979 Expert 512MB
Each time a user browses your site they will be given a unique session ID which you can use to identify them.

You can use the Session_OnStart event in the global.asax to record the time a session begins and the Session_OnEnd event to record the time that it finishes.

Hope this helps,

Dr B
May 20 '08 #2
Hi
Thanks for the quick Reply but Session_OnStart & Session_OnEnd events not get fired when i run my application even i tried with Session_Start & Session_End events these events are also not fired.

Each time a user browses your site they will be given a unique session ID which you can use to identify them.

You can use the Session_OnStart event in the global.asax to record the time a session begins and the Session_OnEnd event to record the time that it finishes.

Hope this helps,

Dr B
May 20 '08 #3
DrBunchman
979 Expert 512MB
They should be firing, what have you done to test them?
May 22 '08 #4
Then inside session_start and session_end, what i must write inside to tracking visitor and get a session who see my website?
tx
May 23 '08 #5
Curtis Rutland
3,256 Expert 2GB
Then inside session_start and session_end, what i must write inside to tracking visitor and get a session who see my website?
tx
Well, it depends on how you want to track them. I would insert a record into a database, containing the time and the user's ip address. But from what I've seen, the session_end event is unreliable, because it won't get called when someone just navigates away.
May 23 '08 #6
Frinavale
9,735 Expert Mod 8TB
Hi
Thanks for the quick Reply but Session_OnStart & Session_OnEnd events not get fired when i run my application even i tried with Session_Start & Session_End events these events are also not fired.
What has been suggested here to store a Session variable with the time that the user arrived at every time the user first visits your page.

Now the thing about this is that you never know on your sever when the user leaves the page. Sessions time out after 20 minutes (by default), so your Session_End event will be fired after 20 minutes (because it will time out)....but your user may have left the page well before this 20 minute time out happens.

Therefore, you'll have to write a bit of JavaScript that posts back to your server when the user leaves the page.

The JavaScript event:

window.beforeunload() = functionThatCallsMyASPXPage()

Fries every time your page begins to unload (don't use onunload because by that time you cannot send any more requests to the server). It is in here that you can make a quick Ajax call to your ASPX page to indicate that the user is leaving the page.

Please note that this fires Every Time The Page Unloads. This means that when the user performs a full page postback to your aspx page this event will fire. You will need to write a bit of JavaScript code and apply it every control that performs full page postbacks. This bit of JavaScript will set a boolean that indicates to the function assigned window.beforeunload() event not call the aspx to tell it that the user has left the page.


I probably wouldn't use Session for this problem. I would use cookies instead.

Hope this gets you pointed in the right direction.

-Frinny
May 23 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: hawkon | last post by:
Hi all, I have an important question to ask about how to trap events when the user close the browser window. I'm a ASP programmer and I have s MSSQL database with a user table where I'm able to...
1
by: Robert Oschler | last post by:
This is my current strategy for tracking hyperlink clicking by a site visitor (Internet Explorer example): Using Javascript I: Attach an event to the document "onclick" handler. When a click...
4
by: Paul Lee | last post by:
Hi, I posted a question to this forum a few days ago and got a veyr good response - unfortunately I asked the wrong question (I asked about referring domains, not IPs of visitors). I've got a...
5
by: Peter Jenkins | last post by:
The client for which I do this site www.safenz.org.nz wants stats tracking/a visitor counter, like the one that is there at the moment (at the bottom of the home page). However I would like one...
8
by: gil | last post by:
I'm trying to track how many users are visiting a site and how may are logged in, using application sessions like so: Sub Session_OnStart Session.Timeout = 20 Session("Start") = Now...
4
by: Ben Amada | last post by:
Hello! There are a couple of visitors (out of dozens) to this web page who are causing the following error to occur: "Object reference not set to an instance of an object." I'm actually...
2
by: Nel | last post by:
I have a web site that seems to be getting hammered by lots of bots. Some genuine, some questionable. Some just users that seem to be downloading the site en-masse. I have started using php &...
2
by: Nalaka | last post by:
Hi, I wanted to track visitors in asp.net 2.0 app. So I added code to method Application_PreRequestHandlerExecute..... But, it seems like.. if output cache is enabled on a page, this method...
3
by: Jeff | last post by:
Hey asp.net 2.0 I'm using Request.UserHostAddress and Request.UserHostName to get info about the site visitors. But the only info I get is IP addresses. Isn't there a way I can get more info...
3
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.