Определение отдельного configSource для bindingRedirects и ссылки на него в app.config
Я пытаюсь определить отдельный файл конфигурации (скажем, redirect.config). Этот отдельный файл конфигурации содержит сборочные привязки следующим образом:
<?xml version="1.0" encoding="utf-8" ?>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NServiceBus.Core" publicKeyToken="9fc386479f8a226c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
В app.config я хочу сослаться на этот redirect.config:
<runtime configSource="Redirects.config" />
К сожалению, это не работает вообще. Копировать в выходной каталог установлен на "всегда копировать". Есть идеи? заранее спасибо
1 ответ
Сделайте так, чтобы добавить это к вам web.config
<configuration>
<configSections>
<section name="redirect" type="CustomType"/>
<redirect>
<settings>
<add name="redirectToHome" value="https://abc.com/Home"/>
</setting>
//You may add account node in this section or any other node you want to relate.
</redirect>
</configSections>
</configuration>
Теперь в вашем коде C# назовите его
string url=ConfigurationManager.AppSettings["redirectToHome"]