WCF Cache vs. Page.Cache

I've got two different, but closely related ASP.Net web applications that use the same data on some pages. In both applications I am using the ObjectDataSource control, have EnableCaching="true", and use the same CacheKeyDependency value in both applications.

I would like to make it so that when a new record is inserted or deleted in one application, it clears the cache in both applications. I began by simply clearing cache by using Page.Cache, but soon realized that it does not clear the cache in the other application. Then I added a WCF service to each application; each service clears the cache object in the application it is hosted in. Except that it doesn't...

First, I discovered that System.Web.HttpContext is always null in WCF. Then I tried instantiating a System.Web.Routing.RequestContext object, but its HttpContext object is always null as well.

It all boils down to this: If I set a Page.Cache object, can a WCF service access that same cache object, if the service is hosted in the same application as the page?

Answers


Yes, you need to enable ASP.NET integration for the WCF service. This involves setting the aspNetCompatibilityEnabled attribute for the serviveHostingEnvironment element in config as well as adding the AspNetCompatibilityRequirementAttribute attribute to you service class to indicate that you support it.

More on this subject can be found here on MSDN.


Need Your Help

About iOS development process send game's an “.app” file for test

ios ios-simulator ios-provisioning

I'm an officially iOS developer. My designer lives in different City and I would like to know: Can I send our game's an ".app" file to him to install on his iPhones for test through the iTunes? He

VS2008 Missing C/C++ Header Files

c visual-studio visual-studio-2008

So, I'm working on some network programming in C, and it would seem that I am missing a bunch of standard C/C++ header files. For example, sys/socket.h is not there. A few otheres are missing too l...

Objective-C: int can´t be NAN?

objective-c ios int double nan

It seems that a int in Objective-C can't be NAN.