I've been trying to get the caching element from my web.config but have thus far failed.
When using this code:
Configuration conf = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
I am able to get at the web.configh file. When i use
conf.GetSection("system.web/membership");
I succefuly get the membership section.
When i use
conf.GetSection("system.web/caching");
I get null.
Any ideas ?
part of the web.config below:
<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>
....
Have you casted the return type correctly as OutputCacheSection?
Now say you wanted to get an attribute named connectionString within the first provider node e.g.
you could do something like this