You cannot define any new configuration section handlers beginning with the keyword config

In addition, you can group configuration section handlers into sections by using the <sectionGroup> tag.This tag accepts the name attribute, which specifies the tag you will later use to reference this section. So, we can put this all together as shown in the following sample code:



<sectionGroup name=""> <section name="myAppSettings"

type="System.Configuration.NameValueFileSectionHandler, System"

</sectionGroup> </configSections>

<> <myAppSettings> <add key="tableBackgroundColor" value="lightyellow"

<add key="tableForegroundColor" value="brown"

</myAppSettings> </>


We have one more tag to go over before we go through the creation of a configuration file.This tag is the <location> tag and is used to designate certain configuration options to apply only to specific files or directories.This tag can also be used to lock down configuration options so that they cannot be changed at a lower level. The <location> tag accepts the path and allowOverride attributes. The path attribute enables you to specify a location to apply a set of configuration options to. If you are using the <location> tag within a machine.config file, the path attribute can specify either virtual directories or applications. If you are using it within a web.config file, the path attribute enables you to specify a directory, subdirectory, application, or file. The allowOverride attribute accepts a value of either true or false and enables you to lock down the configuration options.This tag is illustrated in the following code sample:


<location path="myapp.aspx"> <appSettings> <add key="mykey" value="myvalue"

</appSettings> </location>

<location path="secureapp.aspx" allowOverride="false"> <system.web> <identity impersonate="false" userName="dbaccess" password="seCur1e"

</system.web> <appSettings> <add key="secured" value="true"


</location> </configuration>

0 0

Post a comment