简体   繁体   中英

defining separate configSource for bindingRedirects and reference it in app.config

i'm trying to define a separate configuration file (lets say redirect.config). This separate config file contains assemblyBindings as follow:

<?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>

In the app.config I want to reference this redirect.config:

<runtime configSource="Redirects.config" />

Unfortunately it is not working at all. Copy to Output Directory is set to "copy always". Any ideas? Thanks in advance

Do this way add this to you 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>

Now in your C# code call it by

string url=ConfigurationManager.AppSettings["redirectToHome"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM