1 Comments

Solving this wasn’t obvious to me so here’s a short guide for those who encounter the same problem.

If you are using IIS Express and you’re configuring the web sites through the applicationHost.config, you may encounter the following error when accessing your page:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

This may happen if you haven’t configured any application to the root of your site. In my case, the initial configuration looked like the following:

&lt;site name=<span style="color: #006080">"mySite"</span> id=<span style="color: #006080">"1"</span> serverAutoStart=<span style="color: #006080">"true"</span>&gt;

    &lt;application path=<span style="color: #006080">"/"</span>&gt;

        &lt;virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesmySite"</span> /&gt;

    </application>            

    <bindings>

        &lt;binding protocol=<span style="color: #006080">"http"</span> bindingInformation=<span style="color: #006080">":8080:localhost"</span> /&gt;

    </bindings>

</site>

This worked nicely. The problems began when I tried to move my site to the localhost/mySite:

&lt;site name=<span style="color: #006080">"mySite"</span> id=<span style="color: #006080">"1"</span> serverAutoStart=<span style="color: #006080">"true"</span>&gt;

    &lt;application path=<span style="color: #006080">"/mySite"</span>&gt;

        &lt;virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesmySite"</span> /&gt;

    </application>            

    <bindings>

        &lt;binding protocol=<span style="color: #006080">"http"</span> bindingInformation=<span style="color: #006080">":8080:localhost"</span> /&gt;

    </bindings>

</site>

After this change, I couldn’t access my site anymore. I was greeted with the “configuration data for the page is invalid”. But a simple change fixed it:

&lt;site name=<span style="color: #006080">"mySite"</span> id=<span style="color: #006080">"1"</span> serverAutoStart=<span style="color: #006080">"true"</span>&gt;

    &lt;application path=<span style="color: #006080">"/"</span>&gt;

        &lt;virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesfakesite"</span> /&gt;

    </application>            

    &lt;application path=<span style="color: #006080">"/mySite"</span>&gt;

        &lt;virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesmySite"</span> /&gt;

    </application>

    <bindings>

        &lt;binding protocol=<span style="color: #006080">"http"</span> bindingInformation=<span style="color: #006080">":8080:localhost"</span> /&gt;

    </bindings>

</site>

Note. The same applies to the virtualDirectory. You must have one virtualDirectory-setting pointing into your application’s root.