11 Sep 2013

This was perplexing. I rolled out an MVC 4 subsite onto a virtual directory on a PHP (WordPress) site running on IIS 7.5. At first glance the MVC site was working okay, but then I realised that none of the routes were working, returning the following error:

403 - Forbidden: Access is denied.

You do not have permission to view this directory or page using the credentials that you supplied.

Viewing the pages from IE on the server provided a bit more information:

HTTP Error 403.18 - Forbidden

The specified request cannot be processed in the application pool that is configured for this resource on the Web server.

Module: IIS Web Core

Handler: PHP53_via_FastCGI

Well, there was the clue. The WordPress installation was handling the URL routing, even though my MVC site was running in a sub-application. I discovered WordPress was doing this by using an IIS web.config file with a rewrite rule in the root folder. So, the simple way to solve our problem was to override the rewrite rules, in the web.config of the subsite: