简体   繁体   中英

Web.config - multiple values for setting

Given below is the web.config file of an existing asp.net web service program (.asmx file)

The following code sets the value of TEST as EEE.

     <setting name="TEST" serializeAs="String">
       <value>EEEE</value>
      </setting> 

This is accccessed from the code using

TESTIntegrationWS.Properties.Settings.Default.TEST

How do I set multiple values for the the name "TEST" and access it from the code?

Web.config file

<?xml version="1.0" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0,             Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="TESTIntegrationWS.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <TESTIntegrationWS.Properties.Settings>
            <setting name="TEST" serializeAs="String">
                <value>EEEE</value>
            </setting>
            <system.web>
                <compilation debug="true" targetFramework="4.0" />
            </system.web>
        </TESTIntegrationWS.Properties.Settings>
    </applicationSettings>
    <system.web>
        <compilation debug="true" />
    </system.web>
</configuration>

如果要为TEST分配多个值,则可以使用一些分隔符,该分隔符在值中可能不是逗号或分号,并且在代码中可以使用split来获取值数组。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM