tags:

views:

110

answers:

2

Hi all,

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 just a folder, and within that folder it has its own web.config. I'm doing this so each application has its own application related contents, stylesheets, configs etc.

Now I created a custom http module. When adding this to the root web.config, the module is working properly. When adding the http module config to the directory-level web.config (e.g. /Applications/MyApplication/web.config) the module is not initialized anymore. Even though the msdn states that the HttpModules config element is also working at directory level. Anyone knows how to solve this?

+1  A: 

In IIS under your root application select your folder which has own web.cofig with HttpModules defined, right click and select property, on Directory tab click on Create button.

It will create sub application and now HttpModules should work.

Morbia
That is not really a solution tbh. It changes the application's root location. Therefore you need a new bin directory in the sub level and have all previously configured items in the new bin if they are not GAC'd. It effectivly changes your runtime model.I think it's a problem (bug) of not having a physcial folder structure but having virtual directories pointing to different locations on the harddrive which are not ancestor/descendant related! Seems ASP.net is not/partially reading the web.config if its from a v-dir where the folder is not a descendant of the application website folder.
Marvin Smit
Marvin Smit
A: 

Would it not be possible to create a custom config section that lists out the directories you want to include or exclude your module behaviour? Your module could then inspect that to see if it should do it's work based on the request URL.

I know that's not quite what you are asking, but would certainly give you the behaviour you need.

spooner