Stop ASP.NET web.config inheritance

If you are running a site which has an application at the root and other separate applications running in sub/virtual directories, then Settings inheritance could be a problem. Most collections in the web.config have the <remove> tag or <clear> tag to remove irrelevant modules or handlers in the child app.  The problems are found with settings relating to the <pages> tag, which most items in it don't support <remove>. This means if child applications doesn't share or have the same registered controls, masterpages or themes then probably there will be issues.
Read more about inheritance in config files at msdn. Use <location> tag with inheritInChildApplications attribute (Gets or sets a value that indicates whether the settings that are specified in the associated configuration section are inherited by applications that reside in a subdirectory of the relevant application.) to get this issue solved. So to target the main <system.web> wrap it in the location tag as below.

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