Kentico + MVC – Fix the split admin site

One of the options you have when using Kentico with MVC is to split the site into an administrative site and a public-facing site.
This is a nice separation of concerns so I would definitely reccommend this, if budget permits of course.
There’s a small snag with this though. By default a Kentico instance will show you the home page, but there is no content in an MVC site; it doesn’t have layouts and master pages defined in the CMS. Somehow that makes the site end up in an infinite redirection loop.

We’ve had to instruct editors to go to the /Admin url manually. This works but it’s an annoyance the customer doesn’t need.

The workaround
The workaround is to install the IIS URL Rewrite module on the server and add the following rule in web.config:

<system.webServer>
  ...
  <rewrite>
      <rules>
          <rule name="Redirect to admin login" stopProcessing="true">
             <match url="^$" />
             <action type="Redirect" redirectType="Permanent" url="/Admin/CMSAdministration.aspx" />
          </rule>
      </rules>
  </rewrite>
</system.webServer>

Now any request to the root of the site will get redirected to the admin home page.

Auteur: Marnix van Valen

Lead developer en architect