Groups | Blog | Home
all groups > asp.net security > february 2006 >

asp.net security : Retrieving machine.config/web.config values ...


Sunil.Dua
2/8/2006 3:21:27 AM
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.
Dominick Baier [DevelopMentor]
2/8/2006 12:48:19 PM
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.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

[quoted text, click to view]

AddThis Social Bookmark Button