How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Introduction

in this article, we will learn about how to deploy the asp.net core 5 website on a server using Visual Studio 2019.

Step 1 - Account Setup on Server

The first step for deploying Asp.net Core Web API is to create an Account on the hosting provider website that supports the asp.net web application framework and then follow the steps in the given article

  • Create a Website in the hosting panel.
  • Then create the SQLServer Website using the Hosting Panel

Step 2 - Create the project asp.net Core 5 Web API using VS-2019

Create the project using visual studio and select the asp.net core version .Net 5.0 Current.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Give the Name of the project that you want to develop. My Project is ONP (Online Prescription Application).

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Step 3

Set the Live Server Database Connection string in your Application appsetting.json file,

{
"DefaultConnection": "Data Source=SQL5108.site4now.net;Initial Catalog=YOUR ONLINE DB NAME;User Id=YOUR ONLINE DB USERNAME;Password=YOUR ONLINE DB PASSWORD"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

Step 4 - Publish Your Project

After Creating your project and Final Testing from QA Section now it's time to deploy our website. Now go to solution explorer in visual studio 2019.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Now right click on your project and select the option to publish.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Click the Publish option, a new window will appear. Now select the project publication option here you have 5 to 6 options given below,

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Now select the option Import to publish profile.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

After selecting the option Import Profile click next.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

But here a question will probably come to mind --  how to get the published profile.  Just log in to the hosting server that supports Asp.net core website applications and then go to deployment option and get the publish profile file and download in your local system.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

You get this option in your control panel just get the publish profile from and download that file in your system.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Then upload the file in visual studio using the browse option from the downloaded location.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

After uploading the published profile setting file in the visual studio just click on the Finish option and you will get the below window.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Now click on More Actions.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Click the Edit Option.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Click On Connection.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

All the information fetched from the uploaded published profile will automatically upload and this information will automatically save in visual studio for future deployments.

Step 5 - Validate the Connection

In this step  validate the connection with the server and then you can publish your application on the server.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Now you can see that our connection has been validated from visual studio with server, and now we are ready to publish the application.

Now click on Next.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Click Save the Setting.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Now click on publish.

But before the publication just check that your application is  in release mode and the WebHost environment should be in production mode.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Publication of the website has begun.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Our deployment of the website on the server has been successfully completed.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Now we are live on the website.

How To Deploy ASP.NET Core 5 WebAPI Website On Server Using Visual Studio 2019

Conclusion

We learned how to publish our asp.net Core web application using Visual Studio in this article, and in the next post, we'll learn how to deploy our application using FileZilla Software FTP.

 Happy coding.