How could you do to read a web.config开发者_开发百科 file from inside a aspx file?
Thanks!
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>
....
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]
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:
http://odetocode.com/Articles/345.aspx
精彩评论