【问题标题】:Separating handler configuration from web.config for IIS7 (configSource not supported?)将处理程序配置与 IIS7 的 web.config 分开(不支持 configSource?)
【发布时间】:2010-04-12 15:24:27
【问题描述】:

对于 web.config 的 system.web/httpHandlers 部分,我可以使用“configSource”属性来指定外部配置文件,如下所示:

<system.web>
     <httpHandlers configSource="App_Config\httpHandlers_iis6.config" />
</system.web>

这允许我在所有环境中使用相同的处理程序集,而只需将它们维护在一个地方,同时仍允许 appSettings 等内容从一个 web.config 更改为下一个。

不幸的是,与 IIS7 处理程序有关的部分似乎支持相同的技术:

<system.webServer>
    <handlers configSource="App_Config\httpHandlers_iis7.config" /> <!-- not supported -->
</system.webServer>

有什么方法可以将我的处理程序配置与 IIS7 的主 web.config 文件分开?

【问题讨论】:

  • 我也想知道这个。虽然原因有点不同。我想要一个用于 64 位 IIS7.5 的部分,一个用于 IIS7.5 32 位的部分。

标签: asp.net iis-7 web-config


【解决方案1】:

啊 - 我明白了。

这是我在 web.config 中的一行:

<handlers configSource="App_Config\Handlers.xml" />

不是 \ 而不是 /(我被抓住了)

在我的外部文件中,我有:

    <handlers accessPolicy="Read, Write, Script, Execute">
          <remove name="WebServiceHandlerFactory-Integrated"/>
          <remove name="ScriptHandlerFactory"/>


            <remove name="ScriptHandlerFactoryAppServices"/>

    ...
    ...
    ...
              <add verb="GET,HEAD,POST" preCondition="integratedMode" name="SpellChecker" path="GoogleSpellChecker.ashx" type="umbraco

.presentation.umbraco_client.tinymce3.plugins.spellchecker.GoogleSpellChecker,umbraco"/>
          <add verb="POST,GET,HEAD" name="Elmah" path="/umbraco/elmah.axd" type="Westfield.Web.Application.SecureErrorLogPageFactory, Westfield.Web"/>
        </handlers>

它成功了:)

希望这对某人有所帮助。

【讨论】:

  • 你描述的对我不起作用。 system.webServer/handlers 元素不支持“configSource”属性。
  • 嗨,大卫。在我的 Web.config VS2010 中,configsource 属性下划线表示它无法识别它,但我可以向您保证它对我有用。我想重申一下,确保你使用反斜杠,而不是正斜杠(这让我明白了)。
  • 所以当它告诉我它无法识别该属性时我忽略了它
  • 我会被诅咒的,你是对的!我可以发誓我以前尝试过这个精确的设置,但我第一次肯定犯了错误。谢谢!
  • 运行时部分很乐意接受 configSource 属性,但它不读取外部文件
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-15
  • 2022-11-23
  • 2021-07-27
  • 1970-01-01
  • 2015-06-23
  • 2014-10-23
相关资源
最近更新 更多