虚拟目录中的 IIS 配置文件
我有多个网站,它们都具有相同的代码,但应用程序设置不同。 我想将我的应用程序设置放在位于虚拟目录中的单独配置文件中。 这将使我能够拥有跨所有站点共享的所有代码的单个副本,并且每个站点都有不同的虚拟目录。
不幸的是,当我尝试配置它时,IIS 不会处理位于虚拟目录中的配置文件。
如果您有解决方案,我将不胜感激您的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许在您的网络服务器上使用 machine.config 文件是一个合适的替代方案? 否则,您可以在全局文件夹中的某个位置创建一个 web.config 文件,并使用 WebConfigurationManager.OpenMappedWebConfiguration() 方法打开它。
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.
无法使用虚拟目录(甚至无法使用当前网站之外的文件;只能使用当前文件夹或子文件夹)。
跨项目共享设置的一种可能方法是在构建时进行 - 通过复制它,或者使用 VS 中的链接文件将其复制到发布时的文件夹中。
如果您确实需要在服务器上使用此功能,您可以尝试(尽管我不能说它的效果如何)
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.