How could you do to read a web.config file from inside a aspx file?
Thanks!
How could you do to read a web.config file from inside a aspx file?
Thanks!
Are you trying to check application settings? Connection strings?
Go through System.Configuration.ConfigurationManager
.AppSettings[int index or string name]
.ConnectionStrings[int index or string name]
I assume you want to read the AppSetting parts of the web.config. Each diffrent area of the web.config file gets loaded a different way. But the appSetting are intended for user variables.
WebConfigurationManager.AppSettings["VariableName"];
<configuration>
<configSections>
<appSettings>
<add key="VariableName" value="xxxx"/>
</appSettings>
....
ConfigurationManager.AppSettings["YourPropertyHere"];
as in
string connectionString = ConfigurationManager.AppSettings["MyConnectionString"];
If your after the AppSetting section (name/value pairs) then this article will show you a good example of how to read them: