468,554 Members | 1,942 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

Web.config httpModules remove if exists?

We have a problem with Web.config inheritance in two of our
applications. We have an old app which is poorly written and must be
in the root of the server. We have a newer app which runs from a
virtual directory. The apps are not related.

Old app web.config has:

<httpModules>
<add name="a" type="foo.a, foo" />
<add name="b" type="bar.b, bar" />
</httpModules>

So in the new app we get errors that it can't find assemblies "foo"
and "bar'. If we add this to the new app's web.config:

<httpModules>
<remove name="a" />
<remove name="b" />
</httpModules>

it works only on developer machines that have both apps--fails
otherwise (error removing module that doesn't exist).

The only solution we can think of is to create a fake app which has
empty modules with the same names as the old app's modules and install
that on the developer machines that only work on the new app. This
shoud work but is really ugly.

Are there any other options? (fixing the old app is not an option
right now due to resources and the time it would take to fix it and
it's only a problem in development, not testing or production).

Thanks,

Sam

Apr 5 '07 #1
1 2702
Hi Sam,

I've dealt with this sort of thing a few times as well. To be honest the
<removemodules should do the trick though unless you're not removing in
the right place - the problem may show up in any intermediary Virtuals as
well...

One thing that you can look at is loading the modules via code so they don't
show up in the root config file. It would require touching your 1.1 app, but
it's going to be very simple and can be done in global.asax if necessary...

It's easy to do - just manually attach the module in the Init() method of
your HttpApplication instance (ie. global.asax/cs):

public class Global : System.Web.HttpApplication
{
public static xrnsToashxMappingModule Module = new
xrnsToashxMappingModule();
public override void Init()
{
base.Init();

Module.Init(this);
}

}
Hope this helps,

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com/weblog
"Samuel R. Neff" <sa********@nomail.comwrote in message
news:8u********************************@4ax.com...
We have a problem with Web.config inheritance in two of our
applications. We have an old app which is poorly written and must be
in the root of the server. We have a newer app which runs from a
virtual directory. The apps are not related.

Old app web.config has:

<httpModules>
<add name="a" type="foo.a, foo" />
<add name="b" type="bar.b, bar" />
</httpModules>

So in the new app we get errors that it can't find assemblies "foo"
and "bar'. If we add this to the new app's web.config:

<httpModules>
<remove name="a" />
<remove name="b" />
</httpModules>

it works only on developer machines that have both apps--fails
otherwise (error removing module that doesn't exist).

The only solution we can think of is to create a fake app which has
empty modules with the same names as the old app's modules and install
that on the developer machines that only work on the new app. This
shoud work but is really ugly.

Are there any other options? (fixing the old app is not an option
right now due to resources and the time it would take to fix it and
it's only a problem in development, not testing or production).

Thanks,

Sam
Apr 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bill Long | last post: by
3 posts views Thread by Jose Fernandez | last post: by
2 posts views Thread by Mikael Syska | last post: by
reply views Thread by mazdotnet | last post: by
5 posts views Thread by =?Utf-8?B?TUNN?= | last post: by
2 posts views Thread by =?Utf-8?B?YW5vbg==?= | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.