相关疑难解决方法(0)

以编程方式访问web.config的<compilation />部分?

有没有办法访问<compilation />web.config文件中的标记?

我想检查文件中的" debug "属性是否设置为" true ",但我似乎无法弄清楚如何做到这一点.我已经尝试过使用了WebConfigurationManager,但这似乎不允许我进入该<compilation />部分.

更新:

我知道我可以轻松地像XML文档一样加载文件并使用XPath,但我希望框架中已经存在一些可以为我做这件事的东西.似乎会有一些东西,因为已经有方法来获取应用程序设置和连接字符串.

我也尝试过WebConfigurationManager.GetSection()以下几种方法:

WebConfigurationManager.GetSection("compilation")// Name of the tag in the file
WebConfigurationManager.GetSection("CompilationSection") // Name of the class that I'd expect would be returned by this method
WebConfigurationManager.GetSection("system.web") // Parent tag of the 'compilation' tag
Run Code Online (Sandbox Code Playgroud)

所有上述方法都返回null.我假设有一种方法可以进入这个配置部分,因为有一个类已经存在(' CompilationSection'),我只是想不通如何得到它.

.net c# asp.net configuration

10
推荐指数
2
解决办法
6631
查看次数

标签 统计

.net ×1

asp.net ×1

c# ×1

configuration ×1