1

I have two sites(Web Apps),

  • WebAppOne
  • WebAppTwo

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>
HaBo
  • 13,999
  • 36
  • 114
  • 206

1 Answers1

1

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.

MMM
  • 307
  • 8
  • 18
Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • Thank you for pointing it out. Now can I have my Physical path a relative one, instead of absolute path. Based on google search i read its not possible. Wondering if there is a work around for it. – HaBo Jan 13 '16 at 05:10
  • @HaBo it would have to be absolute path, as no base directory info can be used here to support relative path. It does not make sense to use "the root application's root virtual directory's physical path" as you can see that logic is too complex to remember. – Lex Li Jan 13 '16 at 14:26