HttpModule Catch-22

Thursday, January 8, 2004

I have the .Text engine running in an application underneath the ASP.NET Community Starter Kit. This required a bit of fiddling, because the CSK installs an HttpModule at the application root. When a request goes to the Blogs directory (.Text), the ASP.NET runtime doesn't find the CSK module in the .Text /bin directory and throws an exception (the assembly is in the CSK /bin directory - one level higher).

I thought this would be easy to fix with a tweak in the <httpModules> section of the .Text web.config:

    <remove name=“CommunitiesModule“ />

However, I was still getting an exception. After some google searches I determined the workaround is to place the assembly with the HttpModule into the /bin directory of the application which doesn't use the assembly in order for it to then be removed with the above entry.

This makes sense in a Joseph Heller sort of way....

There was only one catch and that was Catch-22, which specified that a concern for one's safety in the face of dangers that were real and immediate was the process of a rational mind. Orr was crazy and could be grounded. All he had to do was ask; and as soon as he did, he would no longer be crazy and would have to fly more missions. Orr would be crazy to fly more missions and sane if he didn't, but if he was sane he had to fly them. If he flew them he was crazy and didn't have to; but if he didn't want to he was sane and had to. Yossarian was moved very deeply by the absolute simplicity of this clause of Catch-22 and let out a respectful whistle.
"That's some catch, that Catch-22," he observed.
"It's the best there is," Doc Daneeka agreed. 


Comments
TJ Friday, January 30, 2004
Interesting, I thought the remove thing would do the trick as well. I am slightly bummed at how this looks like it would work really well. I have an app in a virtual directory underneath my main .Text site and want to reset everything to a default state (&lt;clear /&gt;?). It does not work that easily and I have also noticed that I cannot turn tracing on for the virtual directory as well. Ugh.
Jeremy Cowles Monday, December 12, 2005
I have had this same problem multiple time. If you happen to come up with a proper fix, please let me know. IMO, copying the asm into the directory is a dirty hack and it really seems like MS should have caught this.
Paul Sunday, May 7, 2006
I too am having the same problem with httpModules defined in a parent app that aren't used in the sub app. The httpModules 'remove' and 'clear' directives don't seem to work.

However to avoid having to copy the parent assemblies into the sub-app to be able to remove the httpModules correctly I was wondering if there was a way to force the runtime to check the parent bin folder for assemblies. For example: at present when running the sub-app the runtime looks in the GAC and the sub-app's bin folder for assemblies then throws an exception if not found. Surely there is a way to tell the runtime to look in the parent's bin folder as well. The runtime will then find the httpModule references and can successfully remove then without the needs to hold copies of the files in the sub-app bin folder.

If anyone knows how to do this please let me know as it may be an acceptable work-around for me.

Cheers
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!