|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Retrieving machine.config/web.config values ...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. You can only use ConfigurationSettings for that particular section.
Overall, however, the config files are really just XML files, so you can use something XmlDocument to acquire the file and then using the associated Xml methods to read the values from the config file. -- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient." "Sunil.Dua" <sunilgc***@gmail.com> wrote in message news:1139399966.777529.271260@g47g2000cwa.googlegroups.com... > 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. >
Child control designers
Making ASP.NET 2.0 asp:Wizard control fully Navigatable without mo VS2005 ASP.NET Gridview cells InsertItemTemplate dependant dropdown list problem Defining a ControlParameter of type DateTime for a DataSource Dynamic Control Positioning Convert string to ITemplate Treeview update on postback CheckBox in repeater asp:treeview, expand, index of node |
|||||||||||||||||||||||