Search code examples
sql-serverasp.net-mvcoutputcacheauditing

ASP.Net OutputCache audit page visits


I have an internal corporate web application that has a page that hosts static content (things like announcements) and I decided to implement OutputCaching on this page to reduce the ammount of processing and db calls.

The only problem is that I need to also keep track of who has and hasn't viewed the content. Specifically I need to be able to audit who has seen a specific announcement (The announcement is determined by the GUID id passed to the MVC endpoint)

Is there any way to log who has accessed a page that has been output cached? Anything would be better than nothing, but if the log could be sent to an SQL database, that would be best solution for me.


Solution

  • I would normally log using an ActionFilterAttribute, but according to the stackoverflow article Working with the Output Cache and other Action Filters, that does not work well with the default output cache and instead you could try an alternative called DonutOutputCache.