5

I am basically trying to do the same thing as this question, create a new application within a folder so it could be accessed as follows.

* http://www.domain.com/ < Main App
* http://www.domain.com/newapp < New App

The problem is that newapp is reading the web.config from the Main App, which is causing errors because it doesn't have all the same dlls etc.
For New App, in IIS, the starting point is set at /newapp, so I am not sure why it is reading the web.config from / at all. It is set as it's own application.

I am testing this in IIS6 on XP Pro, so not sure if that makes a difference. The Main App is dotnet 1.1, and New App is 3.0.

Edit: Adding 'inheritInChildApplications to <location> doesn't work in 1.1, you get an error:

Parser Error Message: Unrecognized attribute 'inheritInChildApplications'
Community
  • 1
  • 1
Karen
  • 2,296
  • 3
  • 18
  • 19

2 Answers2

4

This is by design. Web.config is read from the root to the app folder in question. All changes in the root apply through to your app unless your app changes it. Read this MSDN link to get a better understanding of Web.config hierarchy & inheritance.

In order to have your app ignore settings in the root you need to apply the location element with the inheritInChildApplications attribute set to false for the path.

Something like:

<location path="." inheritInChildApplications="false">
 <settings.....>
</location

For example, if you have a section in the root web.config that is specific to the root app only, then wrap the location element around that section. Use the path of "." to indicate you want all items in the path below this app folder to NOT inherit this section.

Kevin LaBranche
  • 20,908
  • 5
  • 52
  • 76
  • I added this around at the root but since that is a 1.1 application it does not recognize it: I get this error when trying to view the page at the root: Parser Error Message: Unrecognized attribute 'inheritInChildApplications' – Karen Mar 31 '10 at 20:37
  • Oh. That would be a problem. This element is for 2.0 and higher. Unless you can get the 1.1 to 2.0 you might be a little stuck since this is by design for how the web.config works. – Kevin LaBranche Apr 01 '10 at 14:47
  • The only thing I found was adding remove tags to the child web.config for each item that is causing issues. ex: . However this makes the child app web.config dependent on the parent so probably not the best option. – Karen Apr 01 '10 at 15:13
  • That is about your only option if you can't change how the applications sit in relation to each other and/or upgrade the 1.1 app. It may be a hack but it's a good one for your situation. Kudos on that. I didn't even think about that myself. :-) – Kevin LaBranche Apr 01 '10 at 19:46
  • another alternative is to throw the assemblies into the sub apps bin folder but this is just as messy – rtpHarry Apr 06 '10 at 10:13
  • @rtpHarry - True and VERRRRYYY True. – Kevin LaBranche Apr 06 '10 at 14:46
  • @klabranche: I needed the exact same thing today (except everything is 3.5, so no problems there). This works perfectly, thanks. – Joe Enos Jul 09 '10 at 00:08
0

As has been said - the inheritInChildApplications doesn't work in .net 1.1.

I have been doing a lot of research in this area and I originally landed here looking for solutions. The subject doesn't make it clear that this is a 1.1 targeted question.

If you are having problems and your apps are 2.0 or above then check out this article for a lot of detailed information information on the inheritInChildApplications attribute:

Community
  • 1
  • 1
rtpHarry
  • 13,019
  • 4
  • 43
  • 64
  • Sorry - I added more detail to the subject to make it more clear. At time of original posting, I didn't realize it was a 1.1 issue. – Karen Apr 10 '10 at 13:50