Is it possible to combine the app.config files and web.config files. I am self-hosting the service and hosting it in IIS and find myself having to edit two different files?
Is it possible to combine the app.config files and web.config files. I am self-hosting
Share
Yes, you could “externalize” your relevant config sections into separate files, and reference those from both
app.configas well as yourweb.config.Any .NET configuration section can be stashed into an external config file, so you can write:
Now, your external files will look exactly like the relevant config section inside your config:
bindings.config
Note: Visual Studio’s editor will complain about the
configSource=attribute – but the Intellisense is mixed up – the configSource attribute is present on each configuration section, and it does work just fine!Note #2: you cannot externalize the entire
<system.serviceModel>since that is a configuration section group – and those do not have any means to be put into external files, unfortunately.