views:

32

answers:

2

I have following in my parent web applications config file

<configuration>

<sectionGroup name="testmodule">
              <section name="testmodule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule"/>
</sectionGroup>

........ i want to prevent child subfolders from inheriting this config section where should i put <location path="." inheritInChildApplications="false">, since config sections should be first child element of configuration file

+2  A: 

This has been answered a couple of times on SO, but incorrectly in my opinion.

The docs, are pretty clear (1)(2):

The following example shows how to use this attribute in a configuration file to specify that the settings defined in the location element for the root of a Web site should not be inherited by child applications:

The InheritInChildApplications property applies only to location-specific configuration settings.

To answer your question, this should suffice:

<configuration>
...
<sectionGroup name="testmodule">
    <section name="testmodule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule"/>
</sectionGroup>
...
<location path="." inheritInChildApplications="false">
    <testModule>
    ....
    </testModule>
</location>

(1) - http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.inheritinchildapplications.aspx

(2) - http://msdn.microsoft.com/en-us/library/ms178692.aspx

Nariman
Thanks Nariman for reply,sorry this doesn't work, issue your suggesion only prevents inheritance of of <testmodule>... </testmodule> section, the issue is child subfolder application of root web application has section group with testmodule but comes from different assembly. so when i add <sectionGroup name="testmodule"> <section name="testmodule" type="URLRewriter.RewriteModuleSectionHandler, URLRewriter"/></sectionGroup> to the child subfolder web config issue still arises
DSharper
I'm not sure that you can have the same section defined differently in a sub-folder; you could make that sub-folder a stand-alone virtual application, in which case it wouldn't inherit any of the settings from the parent; in this scenario, it would also execute in its own app pool; if you don't have InProc dependencies, that's an option as well.
Nariman
A: 

Seems to be no solution for this currently, should avoid using conflicting section groups in web.config file.

DSharper