Click here to Skip to main content
15,894,740 members
Articles / Web Development / ASP.NET

Creating Custom Configurations

Rate me:
Please Sign up or sign in to vote.
4.47/5 (18 votes)
2 Sep 200410 min read 81K   1.7K   70  
Create isolated settings, strongly-typed objects and collections inside your web.config by leveraging the flexibility of .NET to create your own configuration sections and handler.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>   
      <sectionGroup name="CompanyCo">  
         <section name="Portal" type="ConfigurationSampleVB.SampleConfigurationHandler,ConfigurationSampleVB" />
      </sectionGroup>
   </configSections>
    <appSettings>
      <add key="recursiveCopy" value="true" />
      <add key="maxDepth" value="5" />
      <add key="sourceServer" value="10.1.1.2" />
      <add key="sourceServerName" value="BlueBelle" />
      <add key="server1" value="10.0.22.3" />
      <add key="serverName1" value="CottonCandy" />
      <add key="server2" value="10.0.22.4" />
      <add key="serverName2" value="Butterscoth" />
      <add key="server3" value="10.0.22.5" />
      <add key="serverName3" value="Snuzzle" />
      <add key="server4" value="10.0.22.6" />
      <add key="serverName4" value="Minty" />
   </appSettings>
  <system.web> 
    <compilation defaultLanguage="c#" debug="true" />
    <customErrors mode="RemoteOnly" /> 
    <authentication mode="Windows" /> 
    <authorization>
        <allow users="*" />
    </authorization>
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
    <sessionState mode="Off" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
 </system.web>
 <CompanyCo>
   <Portal recursiveCopy="true" maxDepth="5">
      <servers>
         <clear />
         <add name="BlueBelle" address="10.1.1.2" isSource="true" />
         <add name="CottonCandy" address="10.0.22.3" isSource="false" />
         <add name="Butterscoth" address="10.0.22.4" isSource="false" />
         <add name="Snuzzle" address="10.0.22.5" isSource="false" />
         <add name="Minty" address="10.0.22.6" isSource="false" />
      </servers>
   </Portal>
 </CompanyCo>
 
 

</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions