The case is following: we have a main web application that is going to be accesible from root (let’s call it main) and second application which is accesible on path /myapp (let’s call it myapp).
First we need to do is to add main application as a new web site in IIS.
Open IIS Manager and uder Sites node choose “Add Website”. Fill in website details.
As the hostname provide the actual host name like www.mysite.com If everythink went ok you should now be able to nawigate to your site in the browser.
Next step is to add a myapp application and make it available under the /myapp path. That is when you type in for example http://www.mysite.com/myapp you will access the myapp web application.
In the IIS manager we rightclick on the newly created main web site and select “Add Application”. Provide the application alias which essentially is the path to access the application, set the phsical path and tick the Enable Preload checkbox to speed up application startup.
Now we should see following structure tree
So we have the website and nested application ready and working, but here comes the problem. If the main website and nested myapp application use same settings in their the web config files it may ends up with an internal server error when we try to access the application. This is caused by settings inheritance. According to MSDN the configuration is inherited from parent web sites to child web applications.
The solution for that is the inheritInChildApplications attribute which tells the IIS to not inherit particular settings in child applications.
All we need to do is to edit main website’s web.config and wrap all conflictig configuration sections with location tag and set the inheritInChildApplications=”false” attribute on it.
This is how the main website’s web.config looks now (for the brewity inner content of setting sections was removed)
<?xml version="1.0" encoding="utf-8"?>
<location path="." inheritInChildApplications="false" >
That’s it. Now both website and child web application should work without configuration collisions.