问题
I'm trying to move assembly redirects from web.config
into an external file. The reason for it is that I want to keep binding redirect in one place and use it on both debug and production configurations.
It sort of works, but I'm strugling with specifying relative paths.
<configuration>
<!-- this works, but forces me to use the same path on dev and production machines -->
<linkedConfiguration href="file://c:\data\web.runtime.config"/>
<!-- none of those works -->
<linkedConfiguration href="file://web.runtime.config"/>
<linkedConfiguration href="file://..\web.runtime.config"/>
<linkedConfiguration href="file://~/web.runtime.config"/>
</configuration>
I want to keep the web.runtime.config
in the same folder as the rest of the web application. Is it possible to specify a relative path in linkedConfiguration
element?
More info:
I've tested it with IIS Express and ASP MVC application in VS 2015. When monitoring file accesses using SysInternals Process Monitor relative pathes seems to resolve to \\web.runtime.config
(an invalid network path), while when using the absolute path no leading \\
is added.
回答1:
I found a way to specify relative path.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<linkedConfiguration href="file:./RuntimeConfiguration.xml"/>
</assemblyBinding>
来源:https://stackoverflow.com/questions/32128049/using-relative-path-in-assemblybindig-linkedconfiguration-element