我正在尝试定义一个单独的配置文件(比如redirect.config)。这个单独的配置文件包含assemblyBindings,如下所示:
<?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" />
不幸的是它根本不起作用。复制到输出目录设置为“始终复制”。有任何想法吗?提前致谢
答案 0 :(得分:-4)
这样就可以将此添加到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"]