I created a custom http module and want to add this module to the web config. The web application is a project that contains several \"sub applications\". A sub application is j
To echo Marvin Smit's comment, it seems that configuring
under a
in web.config
simply does not work - any modules specified in this fashion are NOT invoked.
What you can do is to specify the module at root level, and have it controlled by an appSetting
, which can be hierarchically specified and overridden as required:
Then within the code for CustomModule
:
private static bool ModuleEnabled()
{
bool appSetting;
if (!bool.TryParse(ConfigurationManager.AppSettings["UseCustomModule"],
out appSetting))
appSetting = false;
return appSetting;
}
ASP.NET will see to it that the appropriate value of UseCustomModule
for our current location is the one we read.