# Install Sitefinity in hybrid ASP.NET Core and MVC mode

## Overview

In this mode, Sitefinity can have both ASP.NET Core and MVC pages. This mode uses the following setup:

<table>
<tbody>
<tr>
<td>

<strong>Types of pages<br>
rendered</strong>

</td>
<td>

<p>ASP.NET Core</p>
<p>ASP.NET MVC</p>

</td>
</tr>
<tr>
<td>

<strong>Backend</strong>

</td>
<td>

Sitefinity CMS<br>
(<em>running on <strong>ASP.NET framework 4.8</strong></em>)

</td>
</tr>
<tr>
<td>

<strong>Frontend</strong>

</td>
<td>

<p>Sitefinity ASP.NET Core Renderer<br>
(<em>running on <strong>ASP.NET Core</strong>, rendering ASP.NET Core pages</em>)</p>
<p>Sitefinity CMS (<em>running on&nbsp;<strong>ASP.NET framework 4.8</strong>,<br>
rendering MVC pages</em>)</p>

</td>
</tr>
</tbody>
</table>

> info  **RECOMMENDATION**: We recommend using this mode to migrate MVC to ASP.NET Core pages.\
> For more information, see [Migrate using a step-by-step approach](https://www.progress.com/documentation/sitefinity-cms/migrate-using-a-hybrid-development-approach).

The following article describes how to install and setup Sitefinity CMS to work with a standalone ASP.NET Core application as renderer.

You first install and configure Sitefinity CMS to work with the Renderer, then install the Renderer NuGet packages in an ASP.NET Core application, and finally, make the required configurations in the Renderer.

# Install Sitefinity in MVC mode

> info **NOTE**: To install Sitefinity CMS using NuGet, you must use Visual Studio 2017 or later. This article uses Visual Studio 2019 as a reference.

To install Sitefinity CMS in a blank web application using a NuGet package, perform the following:

## Create a blank web application

To do this, perform the following:

1. Open Visual Studio.
2. In the toolbar, click *File* » *New Project…*\
   The *Create a new project* window appears.
3. In the *All languages* dropdown, select *C#*.
4. In the *All platforms* dropdown, select *Windows.*
5. And in the *All project types* dropdown, select *Web*.
6. From the list of projects, select *ASP.NET Web Application (.NET Framework)*.
7. In *Project name*, enter a name of your project.\
   For example, enter `SitefinityWebApp`
8. Choose a location to store your project.
9. Enter a name for the solution.\
   For example, enter `SitefinityWebApp`
10. In *Framework*, select *.NET Framework 4.8*.
11. Click *Create*.
12. In the window that appears, select *Empty* and click *Create*.

## Configure Sitefinity NuGet package sources

All the latest Sitefinity NuGet packages are uploaded to [NuGet.org](https://www.nuget.org/). There are certain third-party, legacy and proprietary packages that are not available on NuGet.org but are hosted on a Sitefinity NuGet repository. Therefore, we recommend configuring and using both repositories as package sources.

In Visual Studio, perform the following:

1. In the toolbar, click *Tools » NuGet Package Manager » Package Manager Settings*.
2. In the left pane, expand *NuGet Package Manager*.
3. Select *Package Sources*.
4. Add a new source by clicking the plus (+) button.
5. Configure NuGet.org repository in the following way:
   * In *Name*, enter: `NuGet.org`
   * In *Source*, enter: `https://api.nuget.org/v3/index.json`
6. Add a new source by clicking the plus (+) button.
7. Configure Sitefinity NuGet repository in the following way:
   * n *Name*, enter: `Sitefinity NuGet`
   * In *Source*, enter: `https://nuget.sitefinity.com/nuget`
8. To save your changes, click *OK*.# Install Sitefinity in MVC mode

## Install Sitefinity CMS

> important **IMPORTANT**: When installing Sitefinity CMS 15.3 and newer via NuGet packages, you must use the console, *All* sources as a source and include the following flag to the command: `-IncludePrerelease`. For example: `Install-Package Telerik.Sitefinity.All -IncludePrerelease`.

In Visual Studio, perform the following:

1. In the toolbar, click *Tools* » *NuGet Package Manager* » *Package Manager Console*.\
   The *Package Manager Console* opens.
2. In *Package source*, select *All*. This way you use both *nuget.org* and *nuget.sitefinity.com* as sources.
3. In *Default project*, select the empty project that you have created.
4. Depending on whether you want to install the full Sitefinity CMS package or a light version:
   * To have all Sitefinity CMS modules installed in your project, install the `Telerik.Sitefinity.All` package by entering in the console: `Install-Package Telerik.Sitefinity.All -IncludePrerelease`
   * To have only the core Sitefinity CMS modules installed in your project, install the `Progress.Sitefinity` package by entering in the console: `Install-Package Progress.Sitefinity -IncludePrerelease`

     > info  **NOTE**: With these commands, you install the latest product update. If you want to install a specific version, you must use the command followed by `-Version` and the version number.\
     > For example, enter `Install-Package Telerik.Sitefinity.All -Version 15.3.8500 -IncludePrerelease`

     Proceed by adding any of the desired additional Sitefinity CMS modules. For more information, see [Work with decoupled modules](https://www.progress.com/documentation/sitefinity-cms/work-with-decoupled-modules).
5. Wait until Sitefinity CMS is installed on your empty project.
6. Build your solution.

## Setup the project

1. Open the project in Visual Studio.
2. In the *Solution Explorer*, open the context menu of your newly created project.
3. Click *View* » *View in browser*.\
   Your project starts in a browser.
4. Install your license.\
   After the project initialized in the browser, the *License activation* page appears.\
   Perform procedure [Activate a license](https://www.progress.com/documentation/sitefinity-cms/activate-a-license).
5. Setup the project.\
   After you activate your license, the *Project Startup* page appears.\
   Perform procedure [Setup the project](https://www.progress.com/documentation/sitefinity-cms/set-up-the-project).\
   Sitefinity CMS *Dashboard* appears.

# Install Sitefinity in hybrid ASP.NET Core and MVC mode

## Configure Sitefinity CMS

After creating and configuring your ASP.NET Core application, you have to configure your Sitefinity CMS. Perform the following:

1. In Sitefinity CMS backend, navigate to *Administration* » *Web services*.
2. Open the *Default* web service.
3. Under *Who can access the content by this service?*, select *Everyone*.
4. Save your changes.

## Create the ASP.NET Core web application

You install the Renderer in a separate ASP.NET Core application. If you do not have one, create it in the following way:

1. In Visual Studio, navigate to *File* » *New* » *Project…*
2. Click *ASP.NET Core Web Application* » *Next*.
3. In *Project name*, enter `Renderer` and click *Create*.
4. Make sure *ASP.NET Core 9.0* is selected and click *Create*.

## Install the ASP.NET Core Renderer

In your Renderer application, you must install the provided NuGet packages:

* `Progress.Sitefinity.AspNetCore.nupkg`
* `Progress.Sitefinity.AspNetCore.Widgets.nupkg`
* `Progress.Sitefinity.Renderer.nupkg`
* `Progress.Sitefinity.RestSdk.nupkg`
* `Progress.Sitefinity.AspNetCore.FormWidgets.nupkg`

Perform the following:

1. In Visual Studio, navigate to *Tools* » *NuGet Package Manager* » *Manage NuGet Packages for Solution…*
2. In *Package source* dropdown, select *nuget.org*.
3. Open the *Browse* tab, select *Progress.Sitefinity.AspNetCore*, and install it in project *Renderer*.
4. Select *Progress.Sitefinity.AspNetCore.Widgets* and install it in project *Renderer*.

## Configure the ASP.NET Core Renderer

After you have created the project and installed the NuGet packages, you must configure it to connect it to Sitefinity CMS. In Visual Studio, perform the following:

1. In the *Solution Explorer* on the right, select `appSettings.json`.\
   Edit the file to add the Sitefinity-related configurations.

   The file should look in the following way:

   ```JSON
   {
     "Logging": {
       "LogLevel": {
         "Default": "Information",
         "Microsoft": "Warning",
         "Microsoft.Hosting.Lifetime": "Information"
       }
     },
     "AllowedHosts": "*",
     "Sitefinity": {
       "Url": "https://yoursitefinitywebsiteurl",
       "WebServicePath": "api/default"
     }
   }
   ```

2. Select the `Program.cs` file.\
   Edit the file to add the Sitefinity-related configurations.

   The file should look in the following way:

   ```C#
   using Microsoft.AspNetCore.Builder;
   using Microsoft.AspNetCore.Hosting;
   using Microsoft.Extensions.Hosting;
   using Progress.Sitefinity.AspNetCore;
   using Progress.Sitefinity.AspNetCore.FormWidgets;

   var builder = WebApplication.CreateBuilder(args);

   // Add services to the container.
   builder.Services.AddSitefinity();
   builder.Services.AddViewComponentModels();
   builder.Services.AddFormViewComponentModels();

   var app = builder.Build();

   // Configure the HTTP request pipeline.
   if (app.Environment.IsDevelopment())
   {
       app.UseDeveloperExceptionPage();
   }
   else
   {
       app.UseExceptionHandler("/Error");
       app.UseHsts();
   }

   app.UseStaticFiles();
   app.UseRouting();
   app.UseSitefinity();

   app.UseEndpoints(endpoints =>
   {
       endpoints.MapSitefinityEndpoints();
   });

   app.Run();
   ```

3. In the *Solution Explorer* on the right, expand *Properties* and select `launchSettings.json`.

4. Find the object with property `"commandName": "Project"` and edit this object’s `applicationUrl` property.

   The property should look in the following way:\
   `"applicationUrl": "https://localhost:5001;http://localhost:5000"`

5. In the *Visual Studio* toolbar, expand the run button dropdown, and select the launch profile you just edited.\
   In your case, it is named *Renderer*.

   > info  **NOTE**: To debug your solution, you need to use the profile you have configured. Debugging of the *IIS Express profile* is not supported.

6. Build your solution.

## Run the Renderer

To run the Renderer, navigate to *<https://localhost:5001/Sitefinity>* or *<http://localhost:5000/Sitefinity>*

> info **NOTE**: You use these URLs to run the Renderer locally for development purposes. To setup the Renderer for production, you can use on of the hosting scenarios, described in [Hosting configurations](https://www.progress.com/documentation/sitefinity-cms/host-the-asp.net-core-rendered-application).
