ASP.NET Core Deployment Guide

Requirements to install the solutions

  • Windows Server: 2008 or higher
  • IIS Version: 7.0/8.0
  • Libraries: Download and install the required libraries from Setups_3.0.10.

Install the appropriate version of the .NET Core Hosting Bundle for .NET 8.0 on the production machine.

Installation flow

  1. WebApplication Deployment on Visual Studio
  2. Configuring IIS Manager for ASP.NET Core Applications
  3. WebApplication Setup

WebApplication Deployment on Visual Studio

Deployment Recommendations

Requirements: Before starting the application publishing process, ensure you meet the minimum requirements and have the development environment installed. You can check the necessary tools in the installation guide.

When publishing an ASP.NET Core application for IIS deployment, use the following settings:

  • Configuration: Release
  • Target Framework: net8.0
  • Deployment Mode: Framework-dependent
  • Target Runtime: Portable

Although you can target win-x64, it is equivalent to Portable when publishing from a Windows machine.

Publishing Mode

  • Framework-dependent mode: Recommended, as it leverages the high reusability of the .NET framework.
  • Self-contained mode: Not advised at this stage due to the added overhead and reduced reusability.

Instead, ensure the .NET Framework 8.0 runtime is installed on the production system.

WebAdmin Solution

The publication of the solution requires selecting the solution that contains all the publishing configurations.

For the Webadmin solution:

  1. Open the Webadmin solution in Visual Studio.
  2. Perform the publishing in the Administration project.

Application Solution

The publication of the solution requires selecting the solution that contains all the publishing configurations.

For the Application solution:

  1. Open the GenioMVC solution in Visual Studio.
  2. Perform the publishing in the GenioMVC project.

Security in ASP.NET Core Applications

Security in Core is significantly stricter, and only HTTPS deployments are supported. Authentication and other security features may refuse connections if HTTPS is not enabled.

Adjusting HTTPS Settings in appsettings.json

To configure HTTPS behavior, modify the https_redirect property in the appsettings.json file:

  • none: Disables HTTPS redirection for unsecured HTTP requests.
  • redirect: (Default) Replies with a 307 redirect code to HTTP requests.
  • hsts: Strictly enforces HTTPS. (Experimental setting)

If your HTTPS port is not the default or if you have multiple port bindings, configure the port using the https_port property.

Working with Configuration Files

ASP.NET Core does not natively use web.config but relies on appsettings.json. Some configurations have been routed to web.config for retro-compatibility, but many are not observed by the application. The following sections are recognized in web.config:

  • Machine Key
  • Log4net
  • Session Cookie Name and Timeout
  • Authentication Cookie Name

All other configurations are either only read by IIS or are ignored by the application.

Configuring IIS Manager for ASP.NET Core Applications

  1. Open IIS Manager:

    • Navigate to the Windows Control Panel.
    • Go to Administrative Tools.
    • Open Internet Information Services (IIS) Manager.
  2. Configure the Application Pool:

    • Set the .NET CLR Version to No Managed Code.
    • Set the Managed Pipeline Mode to Integrated.
  3. Create Separate Application Pools:

    • Create a separate application pool for each ASP.NET Core application.
    • ASP.NET Core does not support hosting multiple applications in the same application pool.
    • In this example, name the application pools as Webadmin and App.
  4. Elevate Privileges for Administration Portal:

    • Use the application pool created (e.g., Webadmin) to run the Administration Portal with higher privileges.

Website creation

Creating a secondary website is highly recommended for better isolation and security, especially to keep all administration websites running on a different port. Although it’s not mandatory, it ensures enhanced security for your setup.

Steps to Create a Secondary Website:

  1. Click on "Add Web Site…" and fill in the site name, e.g., "Application".
  2. Ensure your application has the HTTPS binding configured:
    • The commonly used port is 443.
    • Configure the SSL certificate for secure communication.

Note: Security in Core is significantly more strict, and only HTTPS deployments are supported.

IIS applications

To run the websites, you need to convert the website folders (the Visual Studio solution publish) into applications. Begin by converting the administration website (WebAdmin), and then proceed with each application.

Steps to Convert and Configure Websites:

  1. Locate the IIS Folder:
    You can access the IIS folder on your local disk at: C:\inetpub\wwwroot

Place the folders resulting from the Visual Studio publish process in this directory.

  1. Setup the Administration Website (WebAdmin):

    • Inside the new site created in the previous section, choose "Add Application".
    • Ensure that you select the correct Application Pool for the administration website. In this case, choose the previously created application pool named WebAdmin.
  2. Setup Other Applications:

    • For the App, follow the same instructions as above to add and configure the application.

NOTE: Always confirm that the correct application pool is assigned for each website or application during the setup.

WebApplication Setup

Open a web browser and in the address bar, type: https://<servername>.<certificate>/<sitename>

  • <servername>: This is your IIS server name. If you didn’t create a secondary website or decided to use another port, use the port you selected.
  • <sitename>: Type the website name plus the word you gave for the administration portal.

Another way to fing the url is in the IIS program. There is a button available to redirect you to the correct website:

  1. Select the application to open (on the left sidebar).
  2. Click on the *`Browse :443 (http)`** link (on the right sidebar).

NOTE: The first application to open should always be the Administrator Portal application!

Once the Administrative Portal is open, if you don't have any previous configuration (Configuracoes.xml file), click on "Create System Configuration". If you already have an old configuration file, paste it into the WebAdmin publish folder.

If you wish to share the configurations made in WebAdmin across your applications, you need to place a file in each application to redirect the configuration location.

Steps to Share Configuration:

  1. In the Application Configuration menu, select the desired application.
  2. In the Download Configuration File section, click on the Configurations.redirect.xml button to download the file.
  3. Paste the downloaded file into the application's publish folder.

Important Notes:

  • If all applications and the administration portal are installed on the same machine:
    You can simply download the Configurations.redirect.xml file and paste it in the application folder without any modifications.

  • If applications and the administration portal are installed on different machines:
    Instead of using the Configurations.redirect.xml, copy and paste the Configuracoes.xml file directly into the respective folders after the main configurations.

    After all configuration you can browse the application.