954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

monitor file access

im trying to find a way to do an action when someone accesses a image file.
example would be someone views 'http://site.com/image.jpg' then say i want to log who has veiwed this file in my database.
ive heard of ad sites doing somethign like this for tracking people but i have a different plan.
i want to avoid having to log it by calling the image from a page using params like 'http://site.com/log.aspx?img=image.jpg' i dotn want to do that.

anyone have ideas how to do this?

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

there is a way of doing this. I use it extensively for tracking as you mentioned. You need to use an http module. Change your image url in the webpage to http://site.com/notanimage.jpg then in your http module you check for the name, do whatever logging you need and then replace the request with the original url ( http://site.com/image.jpg) .

If you need code let me know and i will post some (have to change some of mine not to give commercial secrets away :D) IT is only a few lines :)

f1 fan
Posting Whiz in Training
279 posts since Jan 2006
Reputation Points: 26
Solved Threads: 11
 

there is a way of doing this. I use it extensively for tracking as you mentioned. You need to use an http module. Change your image url in the webpage to http://site.com/notanimage.jpg then in your http module you check for the name, do whatever logging you need and then replace the request with the original url ( http://site.com/image.jpg) .

If you need code let me know and i will post some (have to change some of mine not to give commercial secrets away :D) IT is only a few lines :)

Hi,

Can you send the code snippet to me please on

Thanx in advance..
Rgds,
Ravin

rkayasth
Newbie Poster
1 post since Jan 2009
Reputation Points: 5
Solved Threads: 0
 

Hi,
Heres a simple way to do it without HttpHandlers or mapping extensions to the aspnet_isapi.dll.

1. Add a script manager to your page or master page (tut tut if don’t have one already, this is the AJAX revolution!) Make sure you set the EnablePageMethods property to true). Also make sure the script manager is inside your form tag.
2. Create a public static method in your code behind with [WebMethod] above it and add System.Web.Webservices to your usings. Add your handling code, you could update your database, increment a counter or write to a log file.
3. Add an image to your page which has an onload=”PageMethods.TheNameOfYourPageMethod” attribute.

here's a complete tutorial with code:

http://web2asp.net/2009/01/tracking-visitors-in-aspnet-by-using.html

sedgey
Junior Poster
131 posts since Jan 2007
Reputation Points: 68
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You