简体   繁体   English

如何将页面指向另一个web.config?

[英]How to point a page to a different web.config?

Is it possible for a page in ASP .NET to point to a different web.config? ASP .NET中的页面是否可以指向其他web.config? Example, I have 2 different config files, one is web.config and the other one is web1.config. 例如,我有2个不同的配置文件,一个是web.config,另一个是web1.config。 How can I point the page to web1.config in ASP .NET? 如何将页面指向ASP .NET中的web1.config?

From what I know, you cannot point a page to a different web.config file. 据我所知,您不能将页面指向另一个web.config文件。 However, you can organize your Web Site/Application into sub-folders, with one main web.config file at the root folder and a new web.config file in a sub-folder for sub-folder specific settings. 但是,您可以将网站/应用程序组织到子文件夹中,在根文件夹中有一个主web.config文件,在子文件夹中有一个新的web.config文件,用于特定于子文件夹的设置。 You can then make a copy of this sub-folder and modify its web.config for different settings. 然后,您可以复制此子文件夹,并针对不同的设置修改其web.config。

Instead of making a copy of the files, an idea I have is to set a virtual directory in the sub-folder so that you can reuse the same web site/application and control it with different web.config files. 除了复制文件外,我的一个想法是在子文件夹中设置一个虚拟目录,以便您可以重用相同的网站/应用程序并使用不同的web.config文件进行控制。 I have not tried this before, but I think it's worth a try! 我以前没有尝试过,但是我认为值得尝试!

Web.config Inheritance and Overrides Web.config继承和重写

Each Web.config file applies configuration settings to the directory that it is in and to all of the child directories below it. 每个Web.config文件都会将配置设置应用于它所在的目录及其下的所有子目录。 Settings in child directories can optionally override or modify settings that are specified in parent directories. 子目录中的设置可以选择覆盖或修改父目录中指定的设置。 Configuration settings in a Web.config file can optionally be applied to individual files or subdirectories by specifying a path in a location element. 通过在location元素中指定路径,可以选择将Web.config文件中的配置设置应用于单个文件或子目录。

嵌套的Web.config文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM