We use cookies and similar technologies that are necessary to operate the website. Additional cookies are used to perform analysis of website usage. please read our Privacy Policy

How to Deploy and Host ASP.NET Core Application on Windows IIS/Server

img

Previously, we learned how to develop a basic Razor Pages web application using ASP.NET Core framework (which you can find here).

In today’s post, we are going to learn how to deploy ASP.NET Core Application to ISS. While deploying a web app to Windows ISS isn’t difficult, but the ASP.NET Core hosting is bit different than the ASP.NET framework.

The first thing you need to know when creating a new ASP.NET Core application is that they are actually console applications, containing a program.cs file just like a regular ASP.NET console app.

There are also a few more components that are required to deploy & host your ASP.NET Core app to ISS. For instance, first you have to install .NET Core Windows Server Hosting bundle to host your .NET Core application on ISS.

If this is your first time with ASP.NET Core framework, better follow this step-by-step guide to do it right.

IIS configuration

Windows Desktop Operating Systems

Enable the IIS Management Console and World Wide Web Services.

1. Navigate to Control Panel > Programs > Programs and Features > Turn Windows features on or off (left side of the screen).

IIS Management Console

2. Open the Internet Information Services node. Open the Web Management Tools node.

3. Check the box for IIS Management Console.

4. Check the box for World Wide Web Services.

5. Accept the default features for World Wide Web Services or customize the IIS features. Windows Authentication (Optional)

To enable Windows Authentication, expand the following nodes: World Wide Web Services > Security. Select the Windows Authentication feature.

Windows Authentication

6. If the IIS installation requires a restart, restart the system.

Install the .NET Core Hosting Bundle

Install the .NET Core Hosting Bundle on the hosting system. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module.You can go to the .NET All Downloads page. On the .NET Core runtime download page under Windows, select the Hosting Bundle Installer link to download the .NET Core Hosting Bundle installer and run the installer on the server.

Create a Publish package for the app

With the .net core it is very simple to publish the application using CLI command.dotnet publish is the command that create a publish package for the application.Technically, definition is dotnet publish – Packs the application and its dependencies into a folder for deployment to a hosting system.dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory.

The output includes the following assets:

  • Intermediate Language (IL) code in an assembly with a dll extension.
  • .deps.json file that includes all of the dependencies of the project.
  • .runtime.config.json file that specifies the shared runtime that the application expects, as well as other configuration options for the runtime (for example, garbage collection type).
  • The application’s dependencies, which are copied from the NuGet cache into the output folder.

The dotnet publish command’s output is ready for deployment to a hosting system (for example, a server, PC, Mac, laptop) for execution. It’s the only officially supported way to prepare the application for deployment. Depending on the type of deployment that the project specifies, the hosting system may or may not have the .NET Core shared runtime installed on it.You can check more at dotnet publish.Target the Powershell command line to the root folder of the application and run the command.

image2

As you can see, the application is successfully installed.

Now to host this app on Windows server, you need to use IIS server.

Hosting App to IIS Server…

The default publish folder is bin\$(Configuration)\netcoreapp<version>\publish. The default for $(Configuration) is Debug. In the preceding sample, the <TargetFramework>is netcoreapp2.0

dotnet publish -h displays help information for publish.

The following command specifies a Release build and the publishing directory:

dotnet publish -c Release

Create the IIS site

1.  On the hosting system, create a folder to contain the app’s published folders and files. You can simple copy the publish folder created by dotnet publish.

2.  In IIS Manager, open the server’s node in the Connections panel. Right-click the Sites folder. Select Add Website from the contextual menu.

image5

3. Provide a Site name and set the Physical path to the app’s deployment folder. Provide the Binding configuration and create the website by selecting OK:

image4

4. Under the server’s node, select Application Pools.

5. Right-click the site’s app pool and select Basic Settings from the contextual menu.

6. In the Edit Application Pool window, set the .NET CLR version to No Managed Code:

image6

Now, the application is hosted on IIS.

Final Thoughts…

The top benefits of using ISS server is that ISS offers higher level of management, configurability, and security. But, the biggest benefit of all is Process management in .NET Core development services. It is mainly because the IIS will automatically start your application if it crashes.

Hope you learned how to deploy ASP.NET Core app on ISS. If you face any issue while implementing it, contact to hire dedicated .NET developers for help.

We are here

Our team is always eager to know what you are looking for. Drop them a Hi!

    100% confidential and secure

    Pranjal Mehta

    Pranjal Mehta is the Managing Director of Zealous System, a leading software solutions provider. Having 10+ years of experience and clientele across the globe, he is always curious to stay ahead in the market by inculcating latest technologies and trends in Zealous.

    Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Table Of Contents