【发布时间】:2020-02-14 13:02:47
【问题描述】:
我想在 web.cofig 的用户定义部分中使用 appsettings 值。
<coredistributedcache factory-class="NHibernate.Caches.CoreDistributedCache.Redis.RedisFactory,NHibernate.Caches.CoreDistributedCache.Redis">
<properties>
<property name="configuration">127.0.0.1:6379</property>
</properties>
</coredistributedcache>
我已经像这样在appsetting中定义了配置值
<add key="RedisServer" value="127.0.0.1:6379" />
所以基本上我不想将属性configuration 硬编码为127.0.0.1:6379,我想将其设置为
<property name="configuration">{{RedisServer}}</property>
这可能吗?
或者有没有其他方法可以避免重复?
【问题讨论】:
-
我认为配置本身没有办法。如果您使用像 Octopus 这样的第三方工具来执行部署,您可以使用这样的参数执行配置更新,在这种情况下,两个位置将具有相同的占位符,以替换为 Octopus 中定义的单个值。不过,这可能对本地开发构建并没有真正的帮助。
标签: c# asp.net asp.net-web-api nhibernate