Is there any way to disable Cache (System.Web.Caching.Cache, not OutPut cache fo开发者_如何学Gor aspx page) on web.config or global.asax or else somehow?
From MSDN,
Cache API Configuration Settings
You can configure the application's cache API in your Web.config file. As with the page output cache, application hosters can set configuration properties in the Machine.config file and lock cache configuration settings for all applications. The application cache API is configured in the CacheSection.
You can specify application cache API configuration settings by assigning values to attributes such as DisableExpiration and DisableMemoryCollection within the configuration file's CacheSection.
If the DisableMemoryCollection property is set to true, calls to the cache-related API will have no effect.
Word of caution: If the DisableMemoryCollection property is set to true, the cache does not attempt to collect unused items. Use caution when using this setting, as disabling memory collection can quickly lead to Out of Memory conditions for the application.
you can set it in the web.config or do this programatically,
// Get the application configuration file.
System.Configuration.Configuration config =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
System.Web.Configuration.CacheSection cacheSection =
(System.Web.Configuration.CacheSection)config.GetSection(
"system.web/caching/cache");
cacheSection.DisableMemoryCollection = true;
// Save the configuration file.
config.Save(System.Configuration.ConfigurationSaveMode.Modified);
精彩评论