← Back to development
dev

How to deploy .NET Core app on Windows Server

How to deploy .NET Core app on Windows Server

How to deploy .NET Core app on Windows Server

Okay, you now have your shining .NET Core app finished and ready. But now.. You are wondering, so how am I supposed to show this to the world? Do I just give them the URL localhost:42302? Well, if you’re that, you have definitely reached the right place.

In this post, I am going to show you how to deploy your very own .NET Core app on a Windows Server.

If this is your first time deploying a .NET app, I’d recommend you to go with a Windows server first because there’s less hiccups instead of going with a Linux server. It’s easy, has good GUI and generally a pleasant experience (even if Microsoft haters say otherwise). It is much more energising to see that you successfully deploy an app before moving towards a harder, less forgiving environment.

Prerequisites

These are several assumptions I am going to make:

  1. You are using Visual Studio to develop your .NET Core app.
  2. You have the money to purchase a new Windows Server VPS.
  3. You have the money to purchase a new domain.

What to expect

  1. I am going to deploy a .NET Core app to a brand new Windows Server
  2. I am not going to go into how to install a MSSQL Databasae.

1. Publish your app

Using Visual Studio, simply click Build > Publish.

Add a publish profile.

Select “Folder”.

Leave the Folder location at the default value.

Now, click “Publish”.

Your Solution will now be published at the folder you have selected before.

Purchase Windows Server

Get Windows Server VPS

First, what you have to do is get a Windows Server VPS.

After getting a Windows Server VPS, get the IP address of your server.

Domain

Buy Domain

Purchase your domain. You can purchase from Namecheap.

You can follow a video guide here: How to Buy Your Own .com Domain Name on Namecheap

Update your DNS

Point your DNS to your server.

Configure Web Server

Install MSSQL Server (if you need it)

most of the time, you’d need it.

Install IIS (if not installed)

enable via: Control Panel → Turn Windows features on → Internet Information Services

Install .NET Hosting Bundle

From your Windows server, search for the latest .NET Hosting Bundle.

The latest ASP.NET Core at the time of writing is .NET 10. You can download the .NET Hosting Bundle here.

Setup Folders in Server

This is the style I prefer to organize my files and folders in the server. You may choose your own way if you want.

In C:, create folder “www”.

Then, create folder “yourdomain.com”.

Then, create 2 folders: “misc” and “publish”.

The “misc” folder will be our scratch folder where we leave things in a mess.

Our “publish” folder will contain the build files.

Copy

Copy your the published files to the server.

Create IIS site

Open IIS.

Click “Add Website”. Set App Pool.

Install Win-ACME (for automatic SSL)

Install Win-Acme

Done!