visual-studio-2015iis-expressvirtual-directoryapplicationhost

Virtual directory not being configured as an application in IIS Express VS 2015


I have two sites(Web Apps),

both are running on IIS Express from Visual Studio 2015

Here is my applicatoinhost.config

<site name="WebAppOne" id="2">
                <application path="/" applicationPool="Clr4IntegratedAppPool">
                    <virtualDirectory path="/" physicalPath="C:\Projects\WebAppOne\trunk" />
                    <virtualDirectory path="/SubApp" physicalPath="C:\Projects\WebAppOne\trunk\WebAppTwo" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:8181:localhost" />
                </bindings>
            </site>

When I run WebAppOne from Visual Studio on IIS Express, it is point to Virtual Directory correctly but getting an error with permission.

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application

How can I resolve this, sticking to IIS Express running from Visual Studio in debug mode.

Solution: Thanks to @Lex Li


 <site name="WebAppOne" id="2">
                    <application path="/" applicationPool="Clr4IntegratedAppPool">
                        <virtualDirectory path="/" physicalPath="C:\Projects\WebAppOne\trunk" />
                    </application>
 <application path="/" applicationPool="Clr4IntegratedAppPool">
                        <virtualDirectory path="/SubApp" physicalPath="C:\Projects\WebAppOne\trunk\WebAppTwo" />
                    </application>
                    <bindings>
                        <binding protocol="http" bindingInformation="*:8181:localhost" />
                    </bindings>
                </site>

Solution

  • You're understanding the configuration file incorrectly. The second project should be configured as a separate application with its own root virtual directory pointing to the project folder.

    Your current configuration mistakenly sets it as a second virtual directory under the first application, and then its web.config will lead to such an error.