In the config of Web. config

Source: Internet
Author: User

Add a setting in Web. config.

1. Construct a section between <configsections> </configsections>, as shown in figure

<Configsections>

<Section name = "mysection" type = "system. configuration. namevaluesectionhandler, system"/>

</Configsections>

You can also set a section group and the group can be nested.

<Configsections>

<Sectiongroup name = "mygroup">

<Sectiongroup name = "nestedgroup">

<Section name = "mysection" type = "system. configuration. namevaluesectionhandler, system"/>

</Sectiongroup>

</Sectiongroup>

</Configsections>


2. Add the sections settings between <configuration> </configuration> and the <configsections> </configsections> level.

<Mysection>

<Add key = "key_one" value = "1"/>

<Add key = "key_two" value = "2"/>

</Mysection>

Or use the section group method.

<Mygroup>

<Nestedgroup>

<Mysection>

<Add key = "key_one" value = "1"/>

<Add key = "key_two" value = "2"/>

</Mysection>

</Nestedgroup>

</Mygroup>

3. Read Value

Dim config as namevaluecollection = configurationsettings. getconfig ("mysection ")

Or

Dim config as namevaluecollection = configurationsettings. getconfig ("mygroup/nestedgroup/mysection ")

The above method is used when the configuration type to be added is complicated. For example, the above type is a class. Each of the preceding keys is an attribute in the class.

If the configuration to be added is only a text string, you can directly use the <deleetting> Configuration section

<Deleetask>

<Add key = "AAA" value = "BBB"/>

</Deleetting>

Directly use

Dim X as string = configurationsettings. deleettings ("AAA ")

You can.

 

<Location> </location> Configuration section usage

<Location> </location> is used to apply a set of configurations to a specific application directory.

For example,

<System. Web>

<Compilation defaultlanguage = "VB"/>

</System. Web>

<Location Path = "C # code">

<System. Web>

<Compilation defaultlanguage = "CS"/>

</System. Web>

</Location>

Only in the C # code directory, the default language is C #, and other directories are VB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.