在Asp.Net中集中web.config

时间:2021-12-05 03:24:42

I have almost 20 projects in my web solution which include asp.net web application and windows service projects. These all project contains web.config and app.config respectively.

我的Web解决方案中有近20个项目,包括asp.net Web应用程序和Windows服务项目。这些项目分别包含web.config和app.config。

Now I want to remove this all files and want to place a single web.config file in the solution which will be accessed by all the projects.

现在我想删除所有文件,并希望在解决方案中放置一个web.config文件,所有项目都将访问该文件。

Can anyone suggest me of doing this ? If yes then how the projects will call the web.config from the solution root ?

谁能建议我这样做?如果是,那么项目将如何从解决方案根调用web.config?

1 个解决方案

#1


1  

try to use Shortcut/link instead of physical files. to achieve this:

尝试使用快捷方式/链接而不是物理文件。为了达成这个:

  1. keep only one app.config file (the one you edit most frequently probably, does not matter from which project)

    只保留一个app.config文件(你最常编辑的那个,与哪个项目无关)

  2. at each of the rest projects, remove existing app.config file, then right click your project (or the folder you want to place this app.config), click Add, then select "Existing Item...", at the popup, select the physical one you kept in step 1 and then click the arrow next to the "Add" button, select "Add as Link".

    在每个其余项目中,删除现有的app.config文件,然后右键单击您的项目(或您要放置此app.config的文件夹),单击添加,然后选择“现有项目...”,在弹出窗口中,选择您在步骤1中保留的物理实体,然后单击“添加”按钮旁边的箭头,选择“添加为链接”。

now then all the projects (except the one you selected) will reference the one you kept as a link (shortcut).

现在,所有项目(您选择的项目除外)将引用您保留的项目作为链接(快捷方式)。

#1


1  

try to use Shortcut/link instead of physical files. to achieve this:

尝试使用快捷方式/链接而不是物理文件。为了达成这个:

  1. keep only one app.config file (the one you edit most frequently probably, does not matter from which project)

    只保留一个app.config文件(你最常编辑的那个,与哪个项目无关)

  2. at each of the rest projects, remove existing app.config file, then right click your project (or the folder you want to place this app.config), click Add, then select "Existing Item...", at the popup, select the physical one you kept in step 1 and then click the arrow next to the "Add" button, select "Add as Link".

    在每个其余项目中,删除现有的app.config文件,然后右键单击您的项目(或您要放置此app.config的文件夹),单击添加,然后选择“现有项目...”,在弹出窗口中,选择您在步骤1中保留的物理实体,然后单击“添加”按钮旁边的箭头,选择“添加为链接”。

now then all the projects (except the one you selected) will reference the one you kept as a link (shortcut).

现在,所有项目(您选择的项目除外)将引用您保留的项目作为链接(快捷方式)。