---
title: Starting with MVC development
related:
  - https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/kentico-licensing-for-mvc-applications.md
  - https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/defining-content-structure-on-mvc-sites.md
  - https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/developing-mvc-applications.md
  - https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/deploying-mvc-applications.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

This page provides instructions on how to set up an MVC application together with a Kentico instance so that you have a starting point for further MVC development.

Kentico provides ASP.NET MVC support based on a separate MVC application. The application takes care of the presentation and is separated from the Kentico administration. Both applications access the same database as the Kentico application and content synchronization can be handled by web farms.

> **Info:** **Licensing for MVC applications**
>
> You only need to purchase a license for the MVC application. The additional license for the Kentico administration and one extra web farm server is provided for free. To obtain the additional license, [contact our sales department](http://www.kentico.com/company/contact/our-offices).

## Setting up the Kentico instance

In order to develop an MVC application with Kentico, you need to use a content only site that will serve as a repository for content:

1. Go to the **Sites** application.
2. Click on the **New site wizard** button.
3. Select **Use web template**.
4. Click **Next**.
5. Select the **MVC Blank Site** template from the list.

   ![MVC Blank Site template selection](https://docs.kentico.com/docsassets/k11/starting-with-mvc-development/MVC_Blank_Site_Template.png "MVC Blank Site template selection")
6. Continue with the remaining steps of the wizard and finish creating the new site.

Now edit () your new site and on the **General** tab set the **Presentation URL**. This is the URL that will be used by the MVC application. For example, _http://localhost/MvcApplication_ or _http://www.SiteDomain.com_.

Next, you need to set up a content synchronization mechanism:

1. Go to the **Settings** application.
2. Navigate to **Versioning & Synchronization** -> **Web farm**.
3. Set the **Web farm mode** to **Automatic**.
4. Click **Save**.

> **Note:** **Ensuring unique server names**
>
> The system generates the names of automatic web farm servers by combining the machine name and the virtual directory in which the given application is running. If this combination of variables is not unique in your environment, you need to manually assign unique server names to the web farm servers. For example, this problem can occur if you run your MVC application and Kentico application on the same machine without using virtual directories, e.g. on different domains.
>
> To learn how to set web farm server names manually, see _Step 5_ in [Configuring web farms manually](https://docs.kentico.com/k11/configuring-kentico/optimizing-website-performance/setting-up-web-farms/configuring-web-farm-servers.md#configuring-web-farms-manually).

At this point the content only site and your Kentico instance are set up to be used with an MVC application.

## Setting up the MVC application

Your new MVC application needs to be configured to work with Kentico:

1. Create a new project in Visual Studio.

   - Select the **ASP.NET Web Application (.NET Framework)** project template.
   - Choose the **Empty** template option.
   - Enable the _MVC_ checkbox to add folders and core references for MVC.

     ![Creating a new MVC application in Visual Studio](https://docs.kentico.com/docsassets/k11/starting-with-mvc-development/Empty_MVC_Project.png "Creating a new MVC application in Visual Studio")
2. Right-click the solution and select **Manage NuGet Packages for Solution**.
3. Install the **Kentico.Web.Mvc** integration package into your MVC application project (with all dependencies).
4. Edit the MVC project's main **web.config** file:

   - Add a connection string to your Kentico database. We recommend copying the exact connection string from the _web.config_ file of the related Kentico application project.

     ```xml

     <connectionStrings> 
         <add name="CMSConnectionString" connectionString="Persist Security Info=False;database=Kentico;server=myserver;user id=username;password=mypassword;Current Language=English;Connection Timeout=120;" />
     </connectionStrings>

     ```
   - Copy the value of the **CMSHashStringSalt** _appSettings_ key from the _web.config_ of the Kentico project and add the value into the same key in the MVC project's _web.config_ (it is empty by default). This ensures that the MVC application generates hashes using the same salt value as the Kentico application (for example for [macro signatures](https://docs.kentico.com/k11/macro-expressions/troubleshooting-macros/working-with-macro-signatures.md) or page preview links).

     ```xml

     <appSettings>
         <add key="CMSHashStringSalt" value="e68b9ad6-a461-4707-8e3e-ece73f03dd02" />
         ...
     </appSettings>

     ```
5. In the MVC application's **Global.asax** file, add a using statement for the **Kentico.Web.Mvc** namespace and add the following line in the **Application\_Start** method:

   ```csharp

   using Kentico.Web.Mvc;
   ...

   protected void Application_Start()
   {
       ...

       // Enables and configures the selected Kentico ASP.NET MVC integration features
       ApplicationConfig.RegisterFeatures(ApplicationBuilder.Current);
   }

   ```
6. In the **App\_Start\RouteConfig.cs** file, add a using statement for the **Kentico.Web.Mvc** namespace, and call the **MapRoutes** method (must be called before you map any of your own routes).

   ```csharp

   using Kentico.Web.Mvc;

   public static void RegisterRoutes(RouteCollection routes)
   {
       routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

       // Maps routes to Kentico HTTP handlers.
       // Must be first, since some Kentico URLs may be matched by the default ASP.NET MVC routes,
       // which can result in pages being displayed without images.
       routes.Kentico().MapRoutes();

       ...
   } 

   ```
7. Expand the project's **Properties** folder and create a new class, for example named _WebAssemblyInfo.cs_. Add the **AssemblyDiscoverable** assembly attribute into the class.

   - The attribute allows you to work with [classesgenerated for Kentico objects](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/developing-mvc-applications/generating-classes-for-kentico-objects.md).
   - The attribute is placed into a separate class because the default _AssemblyInfo_ class cannot access code from external libraries in cases where the web project is precompiled with outputs merged into a single assembly (during deployment).

     ```csharp

     using CMS;

     // Ensures that the Kentico API can discover and work with custom classes registered in the MVC web project
     [assembly: AssemblyDiscoverable]

     ```
8. Set a URL for the MVC application:
   - Right-click the MVC project and select **Properties**.
   - Open the **Web** tab.
   - In the **Servers** section, select Local IIS.
   - Set the **Project Url** identical to the **Presentation URL** assigned in your MVC site's settings in Kentico.
   - Click **Create Virtual Directory**.

After you run the MVC application, you can see it within the related Kentico administration interface in the **Web farm** application on the **Servers** tab, as a new server. The server's _Status_ changes to _Healthy_ after a few moments.

You can now continue to [define the content structure](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/defining-content-structure-on-mvc-sites.md) of your site and [develop the MVC application](https://docs.kentico.com/k11/developing-websites/developing-sites-using-asp-net-mvc/developing-mvc-applications.md).
