简体   繁体   English

整合Web.config文件

[英]Consolidating Web.config Files

By default, ASP.NET splits up your web.config so that razor-related items are included in "~/views/web.config" while everything else is put into "~/web.config". 默认情况下,ASP.NET拆分您的web.config,以便将与剃须刀相关的项目包含在“〜/ views / web.config”中,而其他所有内容都放入“〜/ web.config”中。

For me, it would make sense to combine all of it into one so that it would apply to the entire site. 对我而言,将所有内容组合为一个整体是有意义的,以便将其应用于整个网站。 Would there be any downside to doing this? 这样做会有不利之处吗?

As you've seen it's valid to have multiple web.config files in a website, under different folders. 如您所见,在网站的不同文件夹下具有多个web.config文件是有效的。

In your main web.config (at the site root), you can specify different configuration at different folders in the site using the <location> element. 在主web.config (位于站点根目录)中,可以使用<location>元素在站点的不同文件夹中指定不同的配置。 Having a web.config file in that folder (location) instead has the same effect, so consolidation is possible. 相反,在该文件夹(位置)中有一个web.config文件具有相同的效果,因此可以进行合并。

However, I would suggest leaving it be: 但是,我建议将其保留为:

  • It's arguably easier to manage this separate configuration which is specific to the view engine being used. 可以说,管理此特定于正在使用的视图引擎的单独配置可能更容易。
  • Any future maintainers will be familiar to MVC and so expect to see the extra web.config there. 任何未来的维护者都将对MVC熟悉,因此希望在那里看到额外的web.config
  • The same could be said for any Nuget packages which you may need, that expect it to be there also. 对于您可能需要的任何Nuget软件包,也可以这样说,并期望它也在那里。

There's bound to be other reasons too, but they come to mind right now. 当然也有其他原因,但是现在就想到了。

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

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