Retrieving machine.config/web.config values ...

S

Sunil.Dua

Hi All,

My machine.config contains the following setting.

<httpRuntime
executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>

I want to extract the value for max request length through code in C#.

Few experiment i done are here :-
I tried with

'(NameValueCollection)ConfigurationSettings.GetConfig
(SectionName);
When I try to run 'NameValueCollection httpRun =
(NameValueCollection)ConfigurationSettings.GetConfig
("system.web/httpRuntime");'
I get an Invalid cast exception.

Then i tried with

Hashtable config =
(Hashtable)ConfigurationSettings.GetConfig("customSection");
MessageBox.Show(config["Name"].ToString());

It is also not working.

Can you please suggest me some good and secure solution. asap.


Thanks.
 
D

Dominick Baier [DevelopMentor]

Hi,

in 1.1 only connection strings and app settings are exposed programmatically
(all the section classes are internal) - you will have to use plain vanilla
XML Reader...

In 2.0 the story is completely different.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top