27

I've tried wrapping my

<system.web>

with

<location path="." InheritInChildApplications="false">

like this

<location path="." InheritInChildApplications="false">
<system.web>...</system.web>
</location>

But VS 2010 Web Developer Express keeps saying

The 'InheritInChildApplications' attribute is not allowed

When I run my web app there's an error:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Config Error Unrecognized attribute 'InheritInChildApplications'.

My configuration: ASP.NET 4.0 RTM, VS 2010, IIS 7.5

2
  • Did you ever get this to work? I am having the same issue ...
    – ak3nat0n
    Sep 7, 2010 at 18:14
  • nope, I solved my issues in root app but the application in a sub folder never worked.
    – mare
    Sep 8, 2010 at 13:56

4 Answers 4

63

It could be because you don't have a namespace specified on the root node? eg

You need

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

not

<configuration>
6
  • 3
    There is one problem with it... The web transforms doesn't work with the correct namespace...
    – BrunoLM
    Mar 29, 2011 at 0:19
  • Thanks - that also cleaned up a couple of other warning that have been bugging me :)
    – Mark
    Nov 1, 2011 at 5:03
  • This worked for me. Should probably mark this is as the correct answer based on votes.
    – bradjive
    Sep 7, 2012 at 15:05
  • it seems that this schema has problem in loading. When accessing this url directly in browser it is giving error. I think it should an xml file.
    – shashwat
    Jul 3, 2013 at 6:02
  • I don't think it has to refer to an actual file, it just has to match what VS is expecting.
    – Sprintstar
    Jul 10, 2013 at 11:52
16

I think the issue here is that inheritInChildApplications is not a valid attribute of the location node in .net 4.0.

The reason the above fix works is because you are specifically targeting the .net 2.0 configuration schema

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

.net 4.0 privdes a different way of dealing with config inheritance.

See http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx and http://msdn.microsoft.com/en-us/library/ms178692.aspx for more details.

1
  • 1
    seems .net 4 brought the attribute back?
    – dotjoe
    May 17, 2012 at 16:17
9

Shouldn't it be a lowercase 'i'?

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

I have been using it successfully on the last 4 or 5 projects I have worked on. My spec is similar to yours. I'm still using .NET 4 RC. I also include the system.webServer settings within location.

Good luck,

Rich

5
  • Aaarrrgh! LOL! It's capitalized in MSDN manuals, so I used it as such.
    – mare
    Apr 24, 2010 at 19:49
  • Ok, the root website is working now, but the subdirectory (configured as an aplication) still tries to load the contents of my 'namespaces' element.
    – mare
    Apr 24, 2010 at 19:52
  • That sucks. Let me know if it works. It's worth flagging it on MSDN.
    – kim3er
    Apr 24, 2010 at 19:54
  • Have you changed the default application name of the sub app?
    – kim3er
    Apr 24, 2010 at 19:56
  • Can I put that around the entire Web.config or just system.web?
    – Si8
    May 10, 2017 at 14:53
1

I use clear quite often to achieve this:

<configuration>
   <system.web>
  <assemblies>
     <clear>
  <clientTarget>
     <clear>
  <compilation>
     <compilers>
        <clear>
  <httpHandlers>
     <clear>
  <httpModules>
     <clear>
  <serviceDescriptionFormatExtensionTypes>
     <clear>
  <webServices>
     <protocols>
        <clear>
  <soapExtensionTypes>
     <clear>
  <soapExtensionReflectorTypes>
     <clear>
  <soapExtensionImporterTypes>
     <clear>

3
  • I tried this and got the error: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. The configuration section 'clear' cannot be read because it is missing a section declaration Nov 21, 2012 at 9:22
  • Just set it above the nodes you wish to clear. <namespaces> <clear /> or <providers> <clear /> or <appSettings> <clear /> etc etc etc
    – Sparkle
    Nov 21, 2012 at 10:40
  • I don't like turning off the inheritance altogether so I prefer to use clear where I need to.
    – Sparkle
    Nov 21, 2012 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.