To stop or avoid web.config inheritance, there is new feature in ASP.NET 4.0 called inheritInChildApplications. This is an attribute of <location> element of web.config schema. you can use it like <location inheritInChildApplications="false">. You can wrap any web.config group with this <location> element.
For example, you can add in web.config for root ASP.NET application something like this to avoid web.config inheritance.
<location inheritInChildApplications="false">
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
</system.web>
</location>
You can also apply <location> to entire web.config
<configuration>
<location inheritInChildApplications="false">
<appSettings>
</appSettings>
<connectionStrings/>
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
</system.web>
</location>
</configuration>