Last post Sep 29, 2008 01:46 PM by liamsmith
Sep 26, 2008 07:50 PM|liamsmith|LINK
I'm writing an HttpModule, and I want to remove all the event handlers from a specific event. The event is:
What I essentially want is something like this:
However, no method like this exists. Anyone know how I can make this work?
Sep 26, 2008 11:12 PM|vcsjones|LINK
This is actually difficult because the underlying delegate that is fired by .NET is handled using Add / Remove. Normally this would be achieved with Delegate.RemoveAll(), but this cannot be done because it is wrapped - you can only add or remove specific
invocations. More over, ResolveRequestCache is very specialized... rather than doing a += or -= on an event, it does some very interesting logic with an internal class called PipelineModuleStepContainer.
To my knowledge, it is not possible to retreive the invocation list and remove all of them for the ResolveRequestCache event.
Sep 29, 2008 01:46 PM|liamsmith|LINK
If it's not possibe to remove the event handlers, maybe there's another way to get the results I'm looking for.
What I'm trying to do is use a custom HttpModule to change the normal .NET caching mechanism to use MemCacheD (a networked caching system). I've got it working, but it looks like what's happening is that both my event and the regular .NET event that handles
caching are firing, resulting in the cache sometimes going to my system, and sometimes going to regular memory.
Is there any way I can deal with this?