Long time ago since I posted something. Busy time 🙂 So, this post will be a shorter one, just to tell you how to get started with Angular & ASP.NET Core and publish it to an IIS server.

Project Seed

To simplify things, I have taken an existing simpler seed and extended it with ASP.NET Identity and OpenIdDict for token based authentication and authorization.

I changed to use sass instead of css and included logging with nLog and translations via WebApi & DB.

I am currently using Angular 4.1 and will try to update the versions to use always the most recent version of it.

You can find the seed here: https://github.com/damirkusar/angularXcore 

Deploy to IIS

Actually, the project seed has currently everything needed to be deployed to an IIS server. But you need to setup the IIS server and the host running IIS.

Here is a guide from microsoft, but you do not need everything from this page.

Check the following chapters:

IIS configuration (copied from above link)

Install https://www.iis.net/downloads/microsoft/url-rewrite for angular

Enable the Web Server (IIS) server role and establish role services.

Windows desktop operating systems

Navigate to Control Panel > Programs > Programs and Features > Turn Windows features on or off (left side of the screen). Open the group for Internet Information Services and Web Management Tools. Check the box for IIS Management Console. Check the box for World Wide Web Services. Accept the default features for World Wide Web Services or customize the IIS features to suit your needs.

IIS Management Console and World Wide Web Services are selected in Windows Features.

Windows Server operating systems

For server operating systems, use the Add Roles and Features wizard via the Manage menu or the link in Server Manager. On the Server Roles step, check the box for Web Server (IIS).

The Web Server IIS role is selected in the Select server roles step.

The default role services are selected in the Select role services step.

Install the .NET Core Windows Server Hosting bundle

  1. Install the .NET Core Windows Server Hosting bundle on the server. The bundle will install the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse-proxy between IIS and the Kestrel server.
  2. Restart the server or execute net stop was /y followed by net start w3svc from a command prompt to pick up a change to the system PATH.

If you only plan to host self-contained deployments and thus don’t require the .NET Core runtime on the server, you have the option of only installing the ASP.NET Core Module by running the installer from an Administrator command prompt: DotNetCore.1.1.0-WindowsHosting.exe OPT_INSTALL_LTS_REDIST=0 OPT_INSTALL_FTS_REDIST=0


If you use an IIS Shared Configuration, see ASP.NET Core Module with IIS Shared Configuration.

For more information, see ASP.NET Core Module overview and ASP.NET Core Module Configuration Reference.

Configure the website in IIS (Copied from above link)

  1. On the target IIS server, create a folder to contain the application’s published folders and files, which are described in Directory Structure.
  2. Within the folder you created, create a logs folder to hold application logs (if you plan to enable logging). If you plan to deploy your application with a logs folder in the payload, you may skip this step.
  3. In IIS Manager, create a new website. Provide a Site name and set the Physical path to the application’s deployment folder that you created. Provide the Binding configuration and create the website.
  4. Set the application pool to No Managed Code. ASP.NET Core runs in a separate process and manages the runtime.
  5. Open the Add Website window.

Click Add Website from the Sites contextual menu.

Supply the Site name, physical path, and Host name in the Add Website step.

Select Basic Settings from the contextual menu of the Application Pool.

Set No Managed Code for the .NET CLR Version.

Setup Environment Variable for ASP.NET Core

Go via the Advanced system settings to the environment variables and set the correct value. Below you see an example of a staging server. But you can put also production or something that suits you.. keep in mind that you need then a different appsettings.*.json file with the correct settings.

Restart now your whole server.


Web Deploy with Visual Studio

Create a Publish Profile in Visual Studio and click the Publish button to deploy your application.


Enable GZIP compression on IIS or in your app (or both)

For me, the IIS setup worked better.


Enable it on IIS:

Enable Static and Dynamic Compression

Windows 10

enter image description here

Windows server 2012 R2

enter image description here


Configure dynamic types

Back in IIS Manager, go to the page for the SERVER, not the SITE. Click on Configuration

enter image description here

From the dropdown, select system.webServer/httpCompression:

enter image description here

Then click on Dynamic Types and now that you’re in the list editor, think about what types you want compressed. Below an example. The time factor is about 10.

enter image description here

Enable it in the App:

Angular & ASP.NET Core

Also published on Medium.

Tagged on:                 

Leave a Reply


Get every new post on this blog delivered to your Inbox.

Join other followers:

Welcome Damir Kusar

Log in

Lost your password?
%d bloggers like this: