[翻译]  Finding final/effective web.config values (from inherited configurations)

[CHINESE]  查找最终/有效的web.config值(来自继承的配置)


Are there any apps that can show the final configuration as applied to a particular application directory? What I'm picturing is something along the lines of FireBug's CSS viewer.

是否有任何应用程序可以显示应用于特定应用程序目录的最终配置?我想象的是FireBug的CSS查看器。

Basically, it should show the equivalent single web.config file (as if you only had one), with all the values that apply to the directory in question, with each element (or even attribute) annotated with its source (the real .config file it came from).

基本上,它应该显示等效的单个web.config文件(就好像你只有一个),包含适用于相关目录的所有值,每个元素(甚至属性)都用其源代码(真正的.config)注释文件来自)。

This would greatly help deploying applications into foreign environments (eg, customer sites) where they sometimes have strange configs, that add in global includes (eg, they put the include in machine.config, instead of the web.config for that app) or have allowOverride=false, etc.

这将极大地帮助将应用程序部署到外部环境(例如,客户站点),在那里他们有时会有奇怪的配置,添加全局包含(例如,他们将include包含在machine.config中,而不是该应用程序的web.config)或有allowOverride = false等

2 个解决方案

#1


1  

None currently exist that are publicly known, however a viewer could easily be written. I would analyze reflected source of the .NET CLR regarding configuration inheritance and value determination. The code logic that calculates the final configuration for a domain is quite specific, so it makes sense no viewer currently exists for your request and this would be a good starting point for a viewer you envision.

目前没有任何公知的,但观众可以轻松编写。我将分析有关配置继承和值确定的.NET CLR的反映源。计算域的最终配置的代码逻辑是非常具体的,因此对于您的请求来说,目前没有查看器是有意义的,这对于您想象的查看器来说是一个很好的起点。

Regarding making deployments, comparisons and editing config files easier, I personally recommend trying ASPhere. It's currently the best GUI editor for .NET config files, although it is not open source.

关于部署,比较和编辑配置文件更容易,我个人建议尝试ASPhere。它目前是.NET配置文件的最佳GUI编辑器,尽管它不是开源的。

There are of course, additional helpful examples reading / accessing config files:

当然,还有其他有用的示例读取/访问配置文件:

And there are special exceptions for sections, such as "processModel" settings. For more information / overview details, see:

部分有特殊例外,例如“processModel”设置。有关更多信息/概述详细信息,请参阅:

#2


1  

If you know the config sections you are interested in then this will give you the effective settings as a class specifically for those settings. You could then cast the type and retrieve the settings that way and do the same for any sections you're interested in.

如果您知道您感兴趣的配置部分,那么这将为您提供专门针对这些设置的有效设置。然后,您可以转换类型并检索设置,并对您感兴趣的任何部分执行相同操作。

object vals = System.Configuration.ConfigurationManager.GetSection("AppSettings")

However, I don't know of any way to retrieve all of the current config sections if you want to discover all of the sections using code.

但是,如果您想使用代码发现所有部分,我不知道有任何方法可以检索所有当前配置部分。


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号