IIS Config file in virtual directory

丶灬走出姿态 提交于 2019-12-10 10:47:01

问题


I have multiple websites that all have the same code, but different app settings. I want to place my app settings in a separate configuration file that is located in a virtual directory. This will allow me to have a single copy of all of the code shared across all of the sites with a different virtual directory for each site.

Unfortunately, when I try to configure this, IIS doesn't process the config file when it is in a virtual directory.

If you have a solution to this, I would appreciate your help.


回答1:


Maybe using the machine.config file on your web server would be a suitable alternative? Otherwise you could create a web.config file in a global folder somewhere and open it using the WebConfigurationManager.OpenMappedWebConfiguration() method.




回答2:


It's not possible to use a virtual directory (or even files outside of the current website; only the current folder, or a sub-folder).

One possible way to share setting across projects would be to do it at build-time - either by coping it in, or using a Linked File in VS to have it copied to the folder on publish.

If you really need this functionality on the server, you could try (though I can't say how well it would work) a Junction.



来源:https://stackoverflow.com/questions/587537/iis-config-file-in-virtual-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!