1

I have a page which I cache for hours using outputcaching. However, I still want to log each pageview in my database.

It is quite important I get access to my codebehind, as I will use these data to show personalized data.

So my outputcache parameter is:

<%@ OutputCache duration="7200" VaryByParam="*" %>

Solution thoughts...

I guess I basically want donut caching, but I really can't find too much info about it.

Will the substitution control be suitable for this? Would a user control be cached?

What's the best solution to access database to store a pageview, even though we're using outputcaching?

Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182

1 Answers1

1

You can basically create a custom HttpHandler in asp.net and call that handler with appropriate parameters using javascript on page load. That handler will do rest of the things like saving page access related data in database etc.

Let me know if you need more help.

Prashant Lakhlani
  • 5,758
  • 5
  • 25
  • 39
  • So a HTTPHandler would be called at every pageload, even though we have outputcaching enabled? Also, would I have access to session and cookiestate? And how would I know what page the user is visiting? :-) – Lars Holdgaard Oct 27 '12 at 12:32
  • That's right, javascript will call HttpHandler. You will have session and cookie both available in handler. For determining page, you can either pass parameter to handler request or use request referrer. – Prashant Lakhlani Oct 27 '12 at 12:39