Bloggs

 
    Help :: Bloggs

Small Business Web Site Design Brisbane, Australia

 How to Use  

Welcome to my Bloggs and ravings on .NET Web design and IT consultancy.  If you would like to participate in these discussions your welcome.  Simple register with the site and we will send you a confirmation email with a code to allow you to log in.  When you log in the code is required to verify your email address.  Then you can make comment on any articles written.  Thankyou for your participation! 

   
 Print   
 Blog List  
   
 Print   
 Search NewBlog  
   
 Print   
 .net Configuration  
Location: BlogsGeneral DiaryMicrosoft .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

Your name:
Title:
Comment:
Add Comment   Cancel 
   
  

Website Design Brisbane*Web Design Brisbane

FAQ|Articles |Free_Tools|Free Chat|Bloggs