Welcome to AspAdvice Sign in | Join | Help

HttpModule Breaks Sub-Applications Problem Solved

Recently I've been working on a number of HttpModule-based plug-in tools for ASP.NET applications, such as the ASPAlliance CacheManager.  The idea being that these kinds of tools can provide added functionality to existing applications without the need for the application to be changed, recompiled, or migrated to some new architecture (as is required with heavier application frameworks like DNN, CS, etc.).  However, one issue with this approach is that, once the HttpModule reference is added to the root application's web.config file, any subfolder that has been set up as an application will fail if the HttpModule is not added to the GAC, or to every sub-application's bin folder in addition to the root folder's /bin.

Last week, I posted to the ASPInsiders to see if anybody knew of a fix for this, and Scott Forsyth let me know about this gem:

There’s a good solution for this in ASP.NET v2.0 now.  At least if you don’t need the assembly in the vdir.  The <location> tag has a new property called inheritInChildApplications.  All you need to do is wrap your modules and assemblies in that location tag and it won’t inherit in the vdirs.

i.e.

 <location inheritInChildApplications=”false”>
  <system.web>
    <httpModules>
      ….
    </httpModules>
  </system.web>
</location>

I haven't had a chance to test this out yet (and there may be a typo or two in it since it's not tested code), but it sounds like it will do the trick for me.  Hopefully this will correct the problem, and once I verify it I will add it to the instructions for CacheManager and my other plug-in project that's nearly ready, ASPAlliance SimpleCMS, which adds CMS capabilities to any existing ASP.NET application.

Published Monday, August 21, 2006 9:09 AM by ssmith
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: HttpModule Breaks Sub-Applications Problem Solved

This definitely works - I've used it before. And yeah, I didn't know about it until the team told me.
Monday, August 21, 2006 9:28 AM by Dave Sussman

# Free .NET CMS Plugin ASPAlliance.SimpleCMS Launched

Last week SimpleCMS was released as a beta. Please download it and give it a try in your ASP.NET 2.0

Monday, August 28, 2006 9:27 AM by Steven Smith

# re: HttpModule Breaks Sub-Applications Problem Solved

Ah, found this too late. I strugggled with this just yesterday and my solution in the root web was to manually load the module in global.asax in HttpApplication.Init. Works too but this is easier and allows working declaratively.

This could potentially solve a few other issues as well with other settings that shouldn't propagate, but it's always hit or miss what will work inside of the the <location> tag.

Sunday, January 14, 2007 5:57 PM by Rick Strahl

# Busier than a busy thing

This week has been crazy on a secret site that is being launched next week. 3 hours sleep has become

Friday, April 27, 2007 11:49 AM by British Inside

# Isolating Web Settings from Sub-Applications using InheritInChildApplications

A while back, Steve Smith brought up a recurring problem I think most of us have bumped into, which is

Wednesday, June 20, 2007 11:06 AM by J. Ambrose Little

# ASP.NET Sub-Applications within Applications

ASP.NET Sub-Applications within Applications

Thursday, September 13, 2007 6:01 PM by Willie Tilton

# ASP.NET Sub-Applications within Applications

ASP.NET Sub-Applications within Applications

Thursday, September 13, 2007 6:01 PM by WTF Blog

# ASP.NET Web.Config Inhertiance Solution

ASP.NET Web.Config Inhertiance Solution

Sunday, March 16, 2008 11:42 PM by Queens Dev

# Sub-web Misconfiguration Solution

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Thursday, March 27, 2008 11:31 PM by DotNetKicks.com

# re: HttpModule Breaks Sub-Applications Problem Solved

thank youu

Monday, September 01, 2008 10:15 AM by parke

# re: HttpModule Breaks Sub-Applications Problem Solved

thank youu

Monday, September 01, 2008 10:16 AM by rüya tabirleri

# application acceleration

I’ ve had occasion to try out taksi, it worked well for GDI capture, but for Direct3D capture on the engine I used it failed in CTaksiDX9:: GetFrame during GetRenderTargetData. I’ ve found a solution by disabling the avi feature (I didn’ t need it) and

Tuesday, December 09, 2008 4:16 AM by application acceleration

# re: HttpModule Breaks Sub-Applications Problem Solved

Thanks!

Sunday, December 21, 2008 10:18 PM by Eric Kimmet

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below