[英]cdata in appSettings value attribute
如下所示,在<appSettings>
部分中包含CDATA
屬性會導致錯誤:
<add key="somejey">
<value><CDATA...> <//value>
</add>
需要是由於事實,因為我們要指定包含帶有args的querystring
值的REST服務端點。 這將使用String.Format
在代碼中進行處理,並替換為args值。
我認為我唯一的出路是擁有一個自定義XML文件並讀入該文件並獲取我的價值,而不是使用appsettings
。
根據簡要的評論,您似乎可以在配置文件中添加“自定義配置”部分。
例如:
配置文件可能如下所示:
<configuration>
<!-- Custom Configuration Section -->
<configSections>
<section name="myCustomConfigSection" type="CustomConfigSection"/>
</configSections>
<CustomConfigSection myKey="SomeValue" />
以及類型“ CustomConfigSection”的定義:
public class CustomConfigSection : ConfigurationSection
{
[ConfigurationProperty("myKey")]
public string myKey {get; set;}
}
以下頁面似乎提供了全面的概述:
觀察到相同的錯誤並通過以下方法解決了它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.