We are doing some activity logging in one of our applications, and for performance reasons we obviously don't want to go back to the database every time. So we store this in an object in the Application.Cache with both an absolute and sliding expiration. When the object expires, we flush to the database. We're also setting a cache dependency so when the activity log grows to a particular size, we expire and flush it.
As a catch all, we've also wired up Application_End to flush to the database. Resetting IIS fires this event, but unfortunately it just kills the process after some amount of time - there's no guarantee that the code executes. Even if we're debugging, it disconnects us.
I'm going to try to play around with remoting or calling a WebService, but I don't know if this will really be a viable solution. I was just hoping that maybe the call would execute fast enough - pushing the expensive part out of the race - but there's still no guarantee.
Has anyone else dealt with something similar? What is the best place to capture something like this?
In our case, it's not a huge deal if we lose some activity, and we can reasonably ensure that we're not going to have much outstanding data... but I can imagine scenarios where this is not acceptable.
