IIS Express: solving the "configuration data for the page is invalid"
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:
<site name=<span style="color: #006080">"mySite"</span> id=<span style="color: #006080">"1"</span> serverAutoStart=<span style="color: #006080">"true"</span>>
<application path=<span style="color: #006080">"/"</span>>
<virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesmySite"</span> />
</application>
<bindings>
<binding protocol=<span style="color: #006080">"http"</span> bindingInformation=<span style="color: #006080">":8080:localhost"</span> />
</bindings>
</site>
This worked nicely. The problems began when I tried to move my site to the localhost/mySite:
<site name=<span style="color: #006080">"mySite"</span> id=<span style="color: #006080">"1"</span> serverAutoStart=<span style="color: #006080">"true"</span>>
<application path=<span style="color: #006080">"/mySite"</span>>
<virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesmySite"</span> />
</application>
<bindings>
<binding protocol=<span style="color: #006080">"http"</span> bindingInformation=<span style="color: #006080">":8080:localhost"</span> />
</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:
<site name=<span style="color: #006080">"mySite"</span> id=<span style="color: #006080">"1"</span> serverAutoStart=<span style="color: #006080">"true"</span>>
<application path=<span style="color: #006080">"/"</span>>
<virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesfakesite"</span> />
</application>
<application path=<span style="color: #006080">"/mySite"</span>>
<virtualDirectory path=<span style="color: #006080">"/"</span> physicalPath=<span style="color: #006080">"C:sitesmySite"</span> />
</application>
<bindings>
<binding protocol=<span style="color: #006080">"http"</span> bindingInformation=<span style="color: #006080">":8080:localhost"</span> />
</bindings>
</site>
Note. The same applies to the virtualDirectory. You must have one virtualDirectory-setting pointing into your application’s root.