8

I have a few aspx files in a "Cache" folder in my application and I do not want HttpModules to run for those files in that folder. I tried having a web.config in subdirectory but learned that HttpModules take the root web.config and not that of the subdirectory. Reference 1, Reference2. So I decided to have this directory as a sub application as per suggestion here and here.

So I configure my application,then "add application" , map it to this directory, which already was inside this application and boom, it fails. It works for a static html file, but aspx files are not available.

My question is, how do I configure a sub-application in IIS7 so that the sub-application can have its own web.config and there I can disable HTTPModules of the root application

Edit:In fact I tried creating a subapplication within my main application and it did not work. Can some one point me to any article on how to configure a sub-application in IIS7 ?

Edit2: adding the error image. So how should I configure the child app pool. The child app runs in the same app pool as that of parent

Edit3: sorry, the child was running on a different app pool. A generic app worked(without modules). I am marking the answer after I try out the modules.Thanks for your help guys. There is something specific in my parent app web.config, which I am going to hunt down now.

alt text

EDIT: Actually both the answers provided below are correct. If you are using IIS7 integrated mode your modules should be in system.webServer and if IIS7 - classic mode your modules (and handlers?) should be in system.web

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
ram
  • 11,468
  • 16
  • 63
  • 89
  • Here's an article on setting up IIS7 sites, applications and virtual directories... http://mvolo.com/blogs/serverside/archive/2007/07/12/Creating-IIS7-sites_2C00_-applications_2C00_-and-virtual-directories.aspx http://www.bloggingdeveloper.com/post/Creating-IIS7-sites-applications-and-virtual-directories-using-Internet-Information-Services-Manager.aspx – JKG Jan 29 '10 at 19:42
  • Glad to help, let us know if you still can't track down the other issue. – JKG Jan 29 '10 at 21:54
  • found that bug too. The dev who was supposed to remove the log4net section did not remove it, removing it resolves the issue. Totally unrelated !!! – ram Jan 29 '10 at 22:19

2 Answers2

9

JKG has the right answer for IIS6, but the syntax is a little different in IIS7:

<system.webServer>
  <modules>
    <remove name="MyModule"/>
  </modules>
</system.webServer>
Matt Connolly
  • 1,233
  • 2
  • 13
  • 20
5

The web.config will always inherit from its parent if it's in the same web application but you can clear the entire thing or remove an item like so:

From the child web.config (clear all or remove an item)

<httpModules>
  <clear />
  <remove name="MyModule"/>
</httpModules>  

From the parent config by using the location tag...

<location inheritInChildApplications="false">
  <system.web>
    <!-- ... -->
  </system.web>
</location>

http://www.jaylee.org/post/2008/03/Prevent-ASPNET-webconfig-inheritance-and-inheritInChildApplications-attribute.aspx

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
JKG
  • 4,369
  • 2
  • 17
  • 10
  • Hmmm, that really should work. Have you tried this with just a simple folder and with the sub application? More examples... http://www.aspdotnetfaq.com/Faq/how-to-disable-web-config-inheritance-for-child-applications-in-subfolders-in-asp-net.aspx http://stackoverflow.com/questions/367282/disable-web-config-inheritance – JKG Jan 29 '10 at 19:22
  • Yes, I am trying to have a very simple "MainApp" and a "SubApp" as a subapplication of MainApp. Any html inside MainApp/SubApp works, but any call to http://MainApp/SubApp/myPage.aspx fails. I have updated the question too with this problem – ram Jan 29 '10 at 19:35
  • Do you mind pasting the exception your getting or the actual error details? That might help. – JKG Jan 29 '10 at 19:38