Configure the application

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

In the previous step of this tutorial, we set up an Xperience application with all prerequisites that we’ll use to present the tutorial website. We also set up a hosting environment for the application using Kestrel.

Now, let’s enable the Xperience features we’ll need for this tutorial – content tree-based routing. In Xperience, some features the system provides need to be explicitly enabled in the application’s startup class. This allows you to enable and configure only the features required by your project.

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 application. All routing logic is handled for you by Xperience. We’ll set up the pages on our tutorial website using this approach.

Configuring the project

  1. Before you edit the project’s code, shut down the application in the Kestrel web server. Press Ctrl+C in the command line prompt where the application is running.

  2. Open the MEDLABClinic.csproj file in Visual Studio.

    • The file is located in the directory where you created the Xperience project
  3. Edit the application’s Program.cs file.

  4. Uncomment the features.UseWebPageRouting() call within builder.Services.AddKentico. This enables the content tree-based routing feature.

  5. Add using statements required for the feature methods (see Add missing usings in Visual Studio). The Program.cs file should now look like this:

    Program.cs
    
    
     using Kentico.Content.Web.Mvc.Routing;
     using Kentico.PageBuilder.Web.Mvc;
     using Kentico.Web.Mvc;
    
     using Microsoft.AspNetCore.Builder;
     using Microsoft.Extensions.DependencyInjection;
    
     var builder = WebApplication.CreateBuilder(args);
    
     // Enable desired Kentico Xperience features
     builder.Services.AddKentico(features =>
     {
         // features.UsePageBuilder();
         // features.UseActivityTracking();
         features.UseWebPageRouting();
         // features.UseEmailStatisticsLogging();
         // features.UseEmailMarketing();
     });
    
     builder.Services.AddAuthentication();
     // builder.Services.AddAuthorization();
    
     builder.Services.AddControllersWithViews();
    
     var app = builder.Build();
    
     ...
    
     // The file continues with the middleware pipeline configuration, which we don't need to modify
    
     
  6. Rebuild the MEDLABClinic projet.

  7. Start your application again (dotnet run in the command line prompt).

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

Previous page: Set up an Xperience by Kentico project —  Next page: Model content

Completed pages: 3 of 9