本文介绍了为什么ConfigurationManager.GetSection" system.webServer /处理器和QUOT;不可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读我的global.aspx 的Application_Start 方法进行一些配置。当我读 ConfigurationManager.GetSection(的System.Web / HttpHandlers的)一切都好:

I'm trying to read some configuration in my global.aspx Application_Start method. When I read ConfigurationManager.GetSection("system.web/httpHandlers") everything is fine:

ConfigurationManager.GetSection(的System.Web / HttpHandlers的)
  {} System.Web.Configuration.HttpHandlersSection
      基地{System.Configuration.ConfigurationSection} {} System.Web.Configuration.HttpHandlersSection
      处理:计数= 48

但是,当我读 ConfigurationManager.GetSection(system.webServer /处理器)(其中包含我的自定义处理程序,它返回。我在做什么错了?

But when I read ConfigurationManager.GetSection("system.webServer/handlers") (which contains my custom handlers, it returns null. What am I doing wrong?

该部分看起来是这样的:

The section looks like this:

<system.webServer>
    <handlers>
        <add verb="*" path="*.loc" name="LocalizedResourceStreamer"
                 type="CFW.WebUI.HttpHandlers.LocalizedResourceStreamer,WebUI" />
    </handlers>
</system.webServer>

注:


  • Web.configs嵌套, ConfigurationManager.GetSection 筑巢需要考虑在默认情况下。

  • 的总体问题是想看看是否被服务* .loc文件。

  • Web.configs are nested, ConfigurationManager.GetSection takes nesting into account by default.
  • The overall problem is trying to see if *.loc files are being served.

到目前为止:

貌似的 system.webServer 的被忽略。

So far:Looks like the system.webServer is ignored.

推荐答案

根据您的OS /设​​置时, system.webServer 元素可以被配置为忽略 - 和这样的配置系统将无法从它建造任何内在的配置项。例如。我的机器(操作系统,IIS 5.1)上,它被设置为默认被忽略掉。

Depending on your OS/setup, the system.webServer element may be configured to be ignored - and so the config system will not be constructing any inner configuration items from it. E.g. on my machine (WinXP, IIS 5.1), it's set to ignored by default.

检查的machine.config 其中,这code运行的机器上,看看如何使用 system.webServer 元素进行配置。我没有可用的时刻合适的以后的操作系统的机器,但它可能是这个元素始终设置为被忽略 - 毕竟,在配置的一部分是为IIS使用,而不是自己的

Check the machine.config on the machine where this code is running, and see how the system.webServer element is configured. I don't have machines available with suitable later OSes at the moment, but it may be that this element is always set to be ignored - after all, that part of the config is for IIS' use, rather than our own.

这篇关于为什么ConfigurationManager.GetSection&QUOT; system.webServer /处理器和QUOT;不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:06