Before we start the deployment process, we would like to point out one important thing. We should always deploy an application in the production environment as soon as we start with development. That way we are able to observe how the application behaves in a production environment from the beginning of the development process.

That leads us to the conclusion that the deployment process should not be the last step of the application’s lifecycle.Ā We should deploy our application to the staging environment as soon as we start building it.

For the purpose of this deployment, we are going to build our Angular application for production to produce optimized static files and to combine them with the .NET Core server.

This process is pretty much the same for any client-side project you want (React, Vue.js or any other).

So, let’s start.

If you want to see all the basic instructions and complete navigation for the .NET Core series, check outĀ the following link:Ā Introduction of the .NET Core series.

For the complete navigation and all the basic instructions of the Angular series, check out: Introduction of the Angular series.

For the previous part check out:Ā Creating Angular client side ā€“ Angular Delete Actions

All required projects and the publish files are availableĀ at GitHubĀ .NET Core, Angular and MySQL. Part 16 – Source Code

This post is divided into several sections:

Building Angular Production Files

First, we need to create the production files for our Angular project by executing the command:

ng build --prod

Building Angular Production Files IIS Deployment

This is the way to create the production files for the Angular project. But if we were to use React or Vue.js for the client-side, the command would be:npm run build

Publishing .NET Core Files for the IIS Deployment

Before we publish our files to the required location, we have to modify our .NET Core app configuration a bit:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    if (env.IsDevelopment())
        app.Use(async (context, next) =>
            await next();
            if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
                context.Request.Path = "/index.html";
                await next();
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see



    app.UseForwardedHeaders(new ForwardedHeadersOptions
        ForwardedHeaders = ForwardedHeaders.All



If we don’t modify our configuration like this, we won’t be able to start our deployed application at all (as soon as we type the required URL address). But with it, we are safe to continue.

Angular CLI is going to create a new folder with the name ā€œdistā€ inside our projectĀ and publish all the production files inside. Copy all those files from the dist folder and paste them into the wwwroot folder inside the .NET Core’s main project. Now with the static files in the right place, we are going to use Visual Studio’s feature to create publish files for the entire application.

Let’s create a folder on the local machine with the name publish. Inside that folder, we want to place all of our files for the deployment. Then, right-click on the AccountOwnerServer project and click theĀ Publish option:

Publish menu IIS Deployment

In the next window, we are going to pick a Folder as the publish target, choose the place where we want to publish our files and click Create Profile:

publish screen

In the next window, we should just click the Publish button.


Now we have all the files in theĀ right place.

Windows Server Hosting Bundle and the Hosts File

Prior to any further action, letā€™s install .NET Core Windows Server Hosting bundle on our system to install the .NET Core Runtime. Furthermore, with this bundle, we are installing the .NET Core Library and the ASP.NET Core Module. This installation will create a reverse proxy between IIS and the Kestrel server, which is crucial for the deployment process.

During the installation, it will try to install the Microsoft Visual C++ 2015 Redistributable, so just let it do that.

If you have a problem with missing SDK after installing Hosting Bundle, follow this solution suggested by Microsoft:
Installing theĀ .NET Core Hosting BundleĀ modifies theĀ PATHĀ when it installs the .NET Core runtime to point to the 32-bit (x86) version of .NET Core (C:\Program Files (x86)\dotnet\). This can result in missing SDKs when the 32-bit (x86) .NET CoreĀ dotnetĀ command is used (No .NET Core SDKs were detected). To resolve this problem, moveĀ C:\Program Files\dotnet\Ā to a position beforeĀ C:\Program Files (x86)\dotnet\Ā on theĀ PATH environment variable.

After the installation, locate the Windows hosts file onĀ C:\Windows\System32\drivers\etc and add the following record at the end of the file:Ā Ā

Finally, save the file.

Installing IIS and the Site Deployment

If you donā€™t have IIS installed on the machine, you need to install it by opening ControlPanel and then Programs and Features:

Installing IIS for IIS Deployment

After the IIS installation finishes, open the Run window (windows key + R) and type: inetmgr to open the IIS manager:

Run window IIS Deployment

Now we can create a new website:

IIS Manager for IIS Deployment

In the next window we need to add a name to our site and a path to the published files:

Add WEbsite IIS Deployment

After this step, we are going to have our site inside the “sites” folder in the IIS Manager. Additionally, we need to set up some basic settings for our application pool:

Application pool IIS Deployment

After we click on the Basic Settings link, let’s configure our application pool:

Edit Application Pool IIS Deployment

Your website and the application pool should be started automatically.

In order to deploy the application to IIS, we need to register the IIS integration in our .NET Core part of the project. We have already done that in our ServiceExtensions class, in Part 2 of this tutorial.


Everything is in place.

Now letā€™s open a browser and type http://www.accountowner.comĀ to inspect the result:

Home screen IIS Deployment

Owner List IIS Deployment


By reading this post you have learned:

  • How to build production files from the client-side application
  • The way to publish files by using Visual Studio
  • Which additional resources we need for IIS deployment to work
  • How to install IIS
  • To deploy the application on IIS

Thank you for reading the post, hopefully, it was helpful to you.

In the next part of the series, we are going to publish this complete application to the Linux environment.