I'm trying to capture the View document "event" of when a user clicks on a document in a document library and it opens up the document in Word or Excel...

There is not such an event receiver and using ItemUpdated or ItemUpdating wouldn't work since those are only triggered when a user edits the properties of that document.

I know there is an audit log which I can access via the object model to get the view count, but the idea is to have a "View Count" column in that document library that displays how many times that document has been viewed or opened. If i use the audit log's view count, I would have to implement some type of timer job that would periodically poll the log and update the "View Count" column.

How do I capture the event when a user opens a document in a document library?

1 Answer 1


As you've found, there is no such event. In my opinion you've described the best solution - a timer job that periodically queries the audit log and updates the "View Count" column.

Another option is to use an HTTP module to capture the request.

  • I wouldn't say the 'only way' as you can always go down the HTTPModule route, but you have to be very careful when you do that (plus it will be messy) Commented Jun 15, 2011 at 5:54
  • @Muhimbi: Do you know if HTTPModules are supported in SP2010?
    – AlexPoint
    Commented Jun 15, 2011 at 6:40
  • HTTPModules are supported in SP2010, and in my experience work better than on SP2007 when capturing streams, although you don't need that for your scenario. Just be very careful when calling into the SP object model as every request goes through he module, resulting in scalability problems if you are not careful. Commented Jun 15, 2011 at 7:57
  • @Muhimbi Good pick up, thanks! I hadn't thought of that and have added it to my answer. Please add another answer if you can give more details on that.
    – Alex Angas
    Commented Jun 15, 2011 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.