Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Weird Issue with HttpModules

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Karch - 12 Feb 2008 02:32 GMT
I have an assembly which contains 2 HttpModule class that inherit from a
base class. The base class simply provides some common methods - nothing
special. The strange thing is that, even though I only specify one or the
other modules in the httpModules section, it seems that both constructors
are called. What is going on here? How do I force it to only load the
HttpModule that is indicated like so:

If I want MyModule1 to be the "active" module, I specify this in the
web.config:

<httpModules>
     <add type="MyAssembly.MyModule1, MyAssembly" name="MyModule1" />
</httpModules>

If I want MyModule2 to be the "active" module, I specify this in the
web.config:

<httpModules>
     <add type="MyAssembly.MyModule2, MyAssembly" name="MyModule2" />
</httpModules>

What am I doing wrong? I keep getting runtime errors from the MyModule1
constructor when I have specified the MyModule2 module (the contructor for
MyModule2 executes as well, by the way). I am using .NET 2.0 Framework.

Thanks,
K
Michael Nemtsev [MVP] - 12 Feb 2008 10:58 GMT
Hello Karch,

Not completely sure, but such behaviour shows that your 2 modules are loaded
when your common base code is initialized, because your modules are located
in the same dll
Why not to put your modules in different dlls? because now they serves as
the single module

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour 

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

K> I have an assembly which contains 2 HttpModule class that inherit
K> from a base class. The base class simply provides some common methods
K> - nothing special. The strange thing is that, even though I only
K> specify one or the other modules in the httpModules section, it seems
K> that both constructors are called. What is going on here? How do I
K> force it to only load the HttpModule that is indicated like so:
K>
K> If I want MyModule1 to be the "active" module, I specify this in the
K> web.config:
K>
K> <httpModules>
K> <add type="MyAssembly.MyModule1, MyAssembly" name="MyModule1"
K> />
K> </httpModules>
K> If I want MyModule2 to be the "active" module, I specify this in the
K> web.config:
K>
K> <httpModules>
K> <add type="MyAssembly.MyModule2, MyAssembly" name="MyModule2"
K> />
K> </httpModules>
K> What am I doing wrong? I keep getting runtime errors from the
K> MyModule1 constructor when I have specified the MyModule2 module (the
K> contructor for MyModule2 executes as well, by the way). I am using
K> .NET 2.0 Framework.
K>
K> Thanks,
K>
Karch - 12 Feb 2008 13:40 GMT
There is a business requirement that they be in the same assembly, and I
don't really see anything unreasonable about that. For exampe, assume I have
20 different modules and I want to deploy only 1 assembly to target
machines. Same thing here.

But, anyway, that's not the answer I was hoping for. The base code being
initialized should have nothing to do with it if I am specifying only one of
them. By the way, the base class, MyBaseModule implements IHttpModule and
then MyModule1 and MyModule2 inherit from MyBaseModule. So:

MyBaseModule : IHttpModule
MyModule1 : MyBaseModule
MyModule2 : MyBaseModule

Nevertheless, when I specify to load MyModule2, I can't see any reason that
MyModule1 would also be loaded.

> Hello Karch,
>
[quoted text clipped - 33 lines]
> K> K> Thanks,
> K> K

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.