I know all about the AspNetCacheProfileAttribute
. But is there any way to hook into the cache programmatically? I've tried using Response.Cache in global.asax which seems to set the correct client-side headers but the response is never cached on the server.
Asked
Active
Viewed 469 times
2

Ladislav Mrnka
- 360,892
- 59
- 660
- 670

roufamatic
- 18,187
- 7
- 57
- 86
-
What do you mean by programmatically? What do you want to achieve? – Ladislav Mrnka Jun 07 '11 at 20:40
-
1I'd like to be able to set my cache policy in code instead of in web.config. This will give me much more flexibility at runtime. – roufamatic Jun 07 '11 at 20:58
1 Answers
1
I don't think you can do it unless you build your own solution. I just checked implementation of AspNetCahceProfileAttribute
which only add internal CachingParameterInspector
to the operation dispatcher. This has two problems:
- Parameter inspector is assigned when the service host starts = during first request and until that it cannot be changed
- Parameter inspector is initialized in its cosntructor by reading cache configuration from the web.config file based on the profile name passed to
AspNetCacheProfileAttribute
There is no API available to modify already assigned and configured parameter inspector

Ladislav Mrnka
- 360,892
- 59
- 660
- 670