Manually setting up ASP.NET Core projects
If you already have an existing Xperience administration instance and do not wish to add new projects using the installer, you can set up a new ASP.NET Core site via the following process:
- Set up a new site in the Xperience administration
- Create and configure a new live site ASP.NET Core project
This process mimics steps the installer performs in the background when installing new ASP.NET Core projects.
Setting up a new site in the Xperience administration interface
Install a new Xperience administration instance or use an existing one.
- Open the Xperience administration interface.
- Navigate to the Sites application.
- Click New site.
- Continue with the remaining steps of the wizard and finish creating the new site.
- Edit your new site and make sure the Presentation URL on the General tab is set correctly. This is the URL that will be used for the site presented by your ASP.NET Core application. For example, http://localhost/CoreApplication or http://www.SiteDomain.com.
- Click Save.
Next, you need to set up the synchronization mechanism:
- Open the Settings application.
- Navigate to Versioning & Synchronization -> Web farm.
- Set the Web farm mode to Automatic.
- Click Save.
At this point the new site and your Xperience instance are set up to be used with an ASP.NET Core application.
Creating a new ASP.NET Core live site project
Open Visual Studio and create a new project.
Select ASP.NET Core Web App.
.NET 6 application templates
The default application template for ASP.NET Core Web Apps in .NET 6 and later is based on minimal APIs. See Hosting ASP.NET Core applications using minimal APIs to learn how to set up the application pipeline using the minimal APIs approach.
- Enter a name for the project and click Create.
Select a template and click Create.
Open the NuGet package manager and install the Kentico.Xperience.AspNetCore.WebApp (with all dependencies).
Open the application’s settings file and:
Add a connection string to your Xperience database. We recommend copying the exact connection string from the web.config file of the related Xperience administration project.
"ConnectionStrings": { "CMSConnectionString": "Persist Security Info=False;database=Xperience;server=myserver;user id=username;password=mypassword;Current Language=English;Connection Timeout=120;" }
Copy the value of the CMSHashStringSalt appSettings key from the web.config of the Xperience project. This ensures that the Core application generates hashes using the same salt value as the Xperience application (for example for macro signatures or page preview links).
"CMSHashStringSalt": "e68b9ad6-a461-4707-8e3e-ece73f03dd02"
In the application’s startup class, add service classes and middleware required by the Xperience integration.
(Optional) Enable additional Xperience features you wish to use in your project.
Configure hosting for the application. This step depends on your environment and requirements. If you are unsure, refer to the Microsoft documentation for help in choosing a suitable hosting model.
The ASP.NET Core web application is now connected to the Xperience administration application. If you run the Core site, the Xperience application registers the connected projected as a new web farm server. You can see it in the Web Farms application in the Xperience administration interface.