<appSettings> 的 <add> 元素

新增自訂應用程式設定。

<configuration>
  <appSettings>
    <add>

Syntax

<appSettings>
  <add key="Key of custom setting" value="Value of custom setting" />
</appSettings>

屬性

描述
key 必要屬性。

指定要新增的索引鍵名稱。
value 必要屬性。

指定要新增的索引鍵值。

父元素

描述
<appSettings> 包含自訂應用程式設定,例如檔案路徑、XML Web 服務 URL,或應用程式的任何其他自訂組態資訊。

子元素

None

範例

下列範例示範如何新增應用程式名稱的自訂組態設定:

<appSettings>
  <add key="ApplicationName" value="MyApplication" />
</appSettings>

下列範例會 <add> 使用 元素在 ASP.NET 應用程式中定義兩個相容性設定:

<appSettings>
  <add key="AppContext.SetSwitch:Switch.System.Globalization.NoAsyncCurrentCulture" value="true" />
  <add key="AppContext.SetSwitch:Switch.System.Uri.DontEnableStrictRFC3986ReservedCharacterSets" value="true" />
</appSettings>

另請參閱