[英]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.