Configuring the Core application

This page is a part of a tutorial, which you should follow sequentially from beginning to end. Go to the first page: Using the Xperience interface.

In the previous step of this tutorial, we’ve installed the Xperience instance that will serve as your site’s content repository and the associated ASP.NET Core application that will be used to present your tutorial website. We’ve also set up a hosting and development environment for the Core application using IIS Express.

Now, we’ll configure the Core application by enabling Xperience’s content tree-based routing and page builder features. In Xperience, some features provided by the system need to be explicitly enabled on the side of the front-end ASP.NET Core application. This allows you to enable and configure only the features you end up using.

With content tree-based routing, the system automatically generates and matches page URLs based on their position in the website’s content tree (demonstrated further in the tutorial). You do not need to perform any manual route mapping and configuration in the Core application. All routing logic is handled for you by Xperience. We’ll set up the pages on our tutorial website using this approach.

The page builder feature enables non-technical users to manage page content via an intuitive drag-and-drop interface. When using the page builder, content editors work with widgets – predefined, configurable pieces of content represented by a partial view or a view component. Fully setting up the page builder is a multistep process that we’ll gradually go through during this tutorial.

Configuring the Core project

  1. Open the MEDIOClinic.sln solution in Visual Studio.

    • The solution is located in the path set by the Target location option during the installation process: C:\inetpub\wwwroot\Xperience13
  2. Open the Core application’s Startup.cs file.

    • The default ASP.NET Core application template provided by the installer contains a middleware pipeline preconfigured to run Xperience projects.
  3. Add all using statements listed in the code example below.

  4. In the ConfigureServices method, uncomment the features.UsePageBuilder() and features.UsePageRouting() lines. This enables the page builder and content tree-based routing features. We’ll use both in the following parts of this tutorial. The ConfigureServices method should now look like this:

    
    
    
     using Kentico.Web.Mvc;
     using Kentico.Content.Web.Mvc;
     using Kentico.Content.Web.Mvc.Routing;
     using Kentico.PageBuilder.Web.Mvc;
    
     using Microsoft.AspNetCore.Builder;
     using Microsoft.AspNetCore.Hosting;
     using Microsoft.AspNetCore.Http;
     using Microsoft.Extensions.DependencyInjection;
     using Microsoft.Extensions.Hosting;
     ...
    
     public void ConfigureServices(IServiceCollection services)
     {
         // Enable desired Kentico Xperience features
         var kenticoServiceCollection = services.AddKentico(features =>
         {
             features.UsePageBuilder();
             // features.UseActivityTracking();
             // features.UseABTesting();
             // features.UseWebAnalytics();
             // features.UseEmailTracking();
             // features.UseCampaignLogger();
             // features.UseScheduler();
             features.UsePageRouting();
         });
    
         if (Environment.IsDevelopment())
         {
             // By default, Xperience sends cookies using SameSite=Lax. If the administration and live site applications
             // are hosted on separate domains, this ensures cookies are set with SameSite=None and Secure. The configuration
             // only applies when communicating with the Xperience administration via preview links. Both applications also need 
             // to use a secure connection (HTTPS) to ensure cookies are not rejected by the client.
             kenticoServiceCollection.SetAdminCookiesSameSiteNone();
    
             // By default, Xperience requires a secure connection (HTTPS) if administration and live site applications
             // are hosted on separate domains. This configuration simplifies the initial setup of the development
             // or evaluation environment without the need for secure connection. The system ignores authentication
             // cookies and this information is taken from the URL.
             kenticoServiceCollection.DisableVirtualContextSecurityForLocalhost();
         }
    
         services.AddAuthentication();
         services.AddControllersWithViews();
     }
    
    
     
  5. Rebuild the MEDIOClinic solution.

You are all set! Your Core application is now configured, and you can start modeling your site’s pages in the next step.

At this point, the live site will only display a “The site has not been configured yet.” message. Don’t worry about this for now, you will create the site’s layout and implement content functionality later in the tutorial.

Previous page: Setting up an Xperience Core project — Next page: Modeling content

Completed pages: 3 of 10