Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I would just like to know if it's possible to list all users who accesses a certain page on a website?

Advance thanks to all.
Neoral
Posted
Comments
Sergey Alexandrovich Kryukov 7-Feb-13 1:33am    
What is "who accessed"? If a user loaded a page and closed it, nothing tells you that she/he is not "accessing" it anymore... Who do you call a user? If you have authentication, it's clear, in other cases, you know nothing about the user, only IP, which can be dynamic. So...
—SA

Please see my comments to the question. You should understand, not quite possible, unless you do authentication.

[EDIT]

If the user is authenticated, it makes more sense.

Still, it would be much better to detect access to your site (log in, log out). Imagine the user loads another page not closing the page you are counting. Is the page in question left or not? You cannot detect activation of the pages, as this is not an event visible to the Web application.

In principle, you can only detect of the user tries to close the page, handling JavaScript event onunload and sending HTTP request to the site using Ajax:
http://www.w3schools.com/jsref/event_onunload.asp[^].

—SA
 
Share this answer
 
v2
Comments
neoraltech 7-Feb-13 1:54am    
Hi Sergey,

Thanks for your prompt response.

The user is authenticated since all users would undergo a login first before they can use the web application.

Thanks.
Neoral
Sergey Alexandrovich Kryukov 7-Feb-13 8:39am    
Good. It makes a lot more sense. Please see my updated answer above, after [EDIT].
—SA
Please follow below steps...

1. Decide in which pages u want to track users
2. Understand the scenario how it should works
3. U should Know how session works

Now in Page_Load() you have to check is there anyone logged in your application through session..

C#
if (Session["useremail"] != null)
        {
            //code to save user information
        }
        else
        {
            // redirect to login page
        }


Here Session["useremail"] stores logged in user details. So if this session exists save the user information like emailid, registration no etc along with page name ( save in database or XML file etc. ). You you will get list of users accessing particular pages.

....
 
Share this answer
 
If you are trying to find out who accesses a page in the past, you can use LogParser to query the IIS Web Logs to see who accessed the URL. This is possible because you have forced the user to login. The Web Logs have columns for both the URL and the UserID.
 
Share this answer
 
Comments
neoraltech 8-Feb-13 2:12am    
Will this have a performance problem for the website? I mean, will it slow down the website when it comes to accessing pages?
It's simple
Decide yourself first whether you want to store the information of the user who access your website (or) want to know who is accessing a particular page in the website.

If you want to know the users who are accessing the entire website use APPLICATION STATE technique, if not go for SESSION STATE
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900