Integrate MVC and Unity and CachingCallHandler

Topics: Building and extending application blocks, Caching Application Block , Enterprise Library Core, Policy Injection Application Block
Sep 12, 2008 at 7:19 AM
Hi All

Is it possible to integrate the MVC, Unity and CachingCallHandler under Enterprise library together?

Now, I worked fine with MVC and unity but it seems don't execute

[CachingCallHandler] attribute.

Do I need to register something?

Thanks and Regards
Sep 12, 2008 at 2:31 PM
You need to use Policy Injection aplication block to leverage CachingCallHandler. Just reference PIAB in MVC project and wrap your classes as following:

foo = PolicyInjection.Wrap<IFoo>( container.Resolve<IFoo>() );
Sep 13, 2008 at 7:39 AM
Thanks, it don't have error now but it seems still haven't cached while I debug it?

Do I need to make the foo as the Singleton with ContainerControlledLifeTimeManager()?

Sep 13, 2008 at 8:59 AM
Actually you have to use the same wrapped foo. It means the instance contained within Unity even it's ContainerControlled is not cache-enabled. Each time you ask Unity for IFoo and wrap the result you got different instances so different caches.