Skip to main content

Publishing to IIS

This guide explains how to configure a Windows server for installing a Lagoon application on IIS. Screenshots from the old documentation have been deliberately removed.

Prerequisites​

  • Processor: minimum 4 cores, 8 cores or more recommended.
  • RAM: minimum 8 GB, 16 GB or more recommended.
  • Disk space: at least 100 GB of free space.

Required software​

  • Operating system: Windows Server 2016 or later.
  • IIS: version 10 or later, with the Web Server role installed.
  • .NET Core Hosting Bundle: contains the .NET Core runtime, the .NET Core library, and the ASP.NET Core module.

Additional considerations​

  • The required memory depends on the number of concurrent users and the complexity of the application.
  • It is recommended to enable WebSockets in IIS for better performance.
  • A valid SSL certificate is required for the HTTPS protocol.
Note

These recommendations are general and may vary depending on the complexity and specific usage of the hosted Blazor WebAssembly application. It is recommended to monitor performance in a development environment to better estimate production needs.

Server configuration​

Installing IIS​

Run the following PowerShell command as administrator to install IIS and the required roles:

Install-WindowsFeature -name Web-Server,Web-WebSockets -IncludeManagementTools

Installing the .NET runtime​

iisreset

IIS configuration​

Creating the physical folder for the application​

  • Copy the files from the delivered folder containing the site into a folder on the application server, for example C:\inetpub\myapproot.
  • Grant read/execute rights to the IIS_IUSRS group on the created folder.

Creating the application pool​

From the IIS Manager:

  • Click Application Pools in the left pane.
  • Click Add Application Pool in the right pane.
  • Create an application pool, selecting No Managed Code for the .NET CLR version.
  • Select the newly created pool, then click Advanced Settings in the right pane.
  • Set the Load User Profile option to True.
Warning

If the user profile is not loaded, the certificate cannot be loaded and the application may return an error such as The antiforgery token could not be decrypted., The system cannot find the file specified., or System.Security.Cryptography.CryptographicException: Access is denied.

  • Optionally, in the case of Windows authentication to SQL Server, change the identity under which the application pool runs.
  • Optionally, set the Start Mode parameter to AlwaysRunning to avoid a wait time on the first access to the application after an IIS restart.

Creating the application in IIS​

Create a new site, or a new application under an existing site, selecting the previously created application pool.

Enable HTTPS, optional​

  • Right-click the new site and choose Edit Bindings....
  • Add a site binding of type HTTPS.

Preloading, optional​

  • Right-click the newly created application, or the newly created site.
  • Choose Manage Application or Manage Website, then Advanced Settings.
  • Set the Preload Enabled option to true.
Note

Preloading should be used together with the AlwaysRunning setting of the application pool for a full pre-initialization of the application.

Application configuration​

appsettings.json​

Edit the appsettings.json file with a text editor:

  • PublicUrl: public URL of the application root, i.e., the one used by end users.
  • Trace log location.
  • Database connection strings.
  • SMTP server.
  • Other application-specific settings.
Warning

The \ character must be doubled in this configuration file. Example: C:\\Temp\\MonApp\\Log.

Web.config​

The Web.config file normally does not need to be modified to configure the application.