我一直在尝试从我的 web.config 中获取缓存元素,但到目前为止都失败了。
使用此代码时:
Configuration conf = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
我可以访问 web.configh 文件。当我使用
conf.GetSection("system.web/membership");
我成功地获得了会员部分。
当我使用
conf.GetSection("system.web/caching");
我得到空值。
有任何想法吗 ?
下面的 web.config 的一部分:
<system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="1000">
<databases>
<clear />
<add name="Tests" pollTime="1000" connectionStringName="TestsConnectionString"/>
</databases>
</sqlCacheDependency>
</caching>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
……