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.
Give the Name of the project that you want to develop. My Project is ONP (Online Prescription Application).
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.
Now right click on your project and select the option to publish.
Click the Publish option, a new window will appear. Now select the project publication option here you have 5 to 6 options given below,
Now select the option Import to publish profile.
After selecting the option Import Profile click next.
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.
You get this option in your control panel just get the publish profile from and download that file in your system.
Then upload the file in visual studio using the browse option from the downloaded location.
After uploading the published profile setting file in the visual studio just click on the Finish option and you will get the below window.
Now click on More Actions.
Click the Edit Option.
Click On Connection.
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.
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.
Click Save the Setting.
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.
Publication of the website has begun.
Our deployment of the website on the server has been successfully completed.
Now we are live on the website.
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.