AngryHacker
AngryHacker

Reputation: 61646

How to retrieve non <appSettings> keys from the web.config?

I have the following in my web.config:

<configuration>
    <system.web>
        <httpRuntime executionTimeout="180"/>
    </system.web>
</configuration>

Is there a .NET built-in way to retrieve executionTimeout value? Perhaps via ConfigurationManager set of objects? I don't see anything obvious.

Upvotes: 0

Views: 341

Answers (1)

amit_g
amit_g

Reputation: 31270

Any section can be retrieved from using GetSection

var httpRuntimeSection = ConfigurationManager.GetSection("system.web/httpRuntime") as 
HttpRuntimeSection;

//httpRuntimeSection.ExecutionTimeout

ExecutionTimeout

In Web app we could use WebConfigurationManager that also has similar API - GetSection

ConfigurationManager vs. WebConfigurationManager

Upvotes: 5

Related Questions