Location: Blogs General Diary Microsoft .NET Application Development |
 |
| Posted by: Conrad Woolston |
Wednesday, June 21, 2006 |
The System.Web.Configuration Manager
The configuration API for ASP.NET developers begins with the WebConfigurationManager class in the System.Web.Configuration namespace.
The WebConfigurationManager includes static (shared) properties to fetch application settings and connection string. For example, to read the “message” appSetting from the web.config we could use the following code:
string message;
message = WebConfigurationManager.AppSettings["test"];
Similarly, if we want to grab the second connection string, the connection with the name of “pubs”, we could use the following code:
string connectionString =
WebConfigurationManager.ConnectionStrings["adconnection"].ConnectionString;
Sample Web.config Section
< configuration>
<appSettings> <add name="test" value="mytest string value"/>
</appSettings>
< connectionStrings>
<!-- <add name="ADConnectionString" connectionString="LDAP://office.surcess.com/CN=Users,DC=eji,DC=domain" />-->
< add name="ADConnectionString" connectionString="LDAP://LANDS/OU=Managed Users,DC=LANDS,DC=resnet,DC=qg"/>
</ connectionStrings>
|
|
| Permalink |
Trackback |
|
|
Website Design Brisbane*Web Design Brisbane
|