InheritInChildApplications attribute not recognized in web.config location element

廉价感情. 提交于 2019-12-20 16:25:12

问题


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


回答1:


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




回答2:


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>



回答3:


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.




回答4:


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>



来源:https://stackoverflow.com/questions/2705857/inheritinchildapplications-attribute-not-recognized-in-web-config-location-eleme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!