简体   繁体   中英

Separating handler configuration from web.config for IIS7 (configSource not supported?)

For the system.web/httpHandlers section of web.config I can use the "configSource" attribute to specify an external configuration file, like so:

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

This allows me to use the same set of handlers across all of my environments while only having to maintain them in one place, while still allowing things like appSettings to change from one web.config to the next.

Unfortunately, it appears that the same technique is not supported for the section pertaining to IIS7 handlers:

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

Is there any way to separate my handlers configuration from the main web.config file for IIS7?

Ah - I've got it.

Here's my line from the web.config:

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

not the \\ rather than the / (I got caught there)

and in my external file I've got:

    <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>

And it worked :)

Hope this helps someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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