以编程方式配置Web.config中的caching.database节点
// Get the Web application configuration.
System.Configuration.Configuration webConfig =
WebConfigurationManager.OpenWebConfiguration("~/");
// Get the section.
System.Web.Configuration.SqlCacheDependencySection sqlDs =
(System.Web.Configuration.SqlCacheDependencySection)webConfig.GetSection(
"system.web/cache/sqlCacheDependency");
System.Configuration.Configuration webConfig =
WebConfigurationManager.OpenWebConfiguration("~/");
// Get the section.
System.Web.Configuration.SqlCacheDependencySection sqlDs =
(System.Web.Configuration.SqlCacheDependencySection)webConfig.GetSection(
"system.web/cache/sqlCacheDependency");