1. How to publish ASP.NET Core web application via Visual Studio 2019
Authoring Tools > Visual Studio 2019
This article contains the most detailed steps for publishing ASP.NET Core web application to our
web server using Visual Studio 2019.
1. Initial Setup at SmarterASP.net
Create a website and a SQL Server database from your hosting Control Panel. For more details,
please check the below links
1. Create a website
2. Create a database
In the section following we will review some of the detail of the setup in order to get the values to
need to publish the project
2. Creating the Project in Visual Studio
Build the project using the Visual Studio templates:
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
1 de 14 01/02/2022 12:11 p. m.
2.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
2 de 14 01/02/2022 12:11 p. m.
3.
Since all your sites are using the same application pool in the hosting plan, please use
OutOfPorcess hosting model for all your ASP.NET Core applications.
You can easily configure the setting in local VS, this will publish the application as OutOfProcess
hostingModel automatically.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
3 de 14 01/02/2022 12:11 p. m.
4.
Please note, in this example, Individual User Accounts is selected for Authentication. This means
that the default build will include a database context “ApplicationDbContext” and a migration for
creating the Identity Schema. Once the project is created and the command "Update-Database" is
run in the VS Package Manager Console, a local database instance is created with a set of tables
associated with the user identity. These can be seen by viewing the "localdb" in the VS SQL Server
Object Explorer.
It is not a requirement to use individual user accounts, however, if the project does not, it will be
necessary to create a database context, add one or more data object, and run the "Add-Migration
Initial" and "Update-Database" commands in the VS Package Manager Console in order to
demonstrate the steps involving the database.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
4 de 14 01/02/2022 12:11 p. m.
5.
3. Preparing to Publish the Project
There are several critical, and somewhat cryptic, values that need to be entered into the VS
Publish dialogs and it is useful to collect these in advance.
For more details on how to find Web Deployment Information
The database connection string can be found by selecting the “Databases” icon from your Control
Panel, and then the “Connection String Examples”. Use the option titled “ASP.NET”.
Note that this string includes the user name and password credential for the database (not to be
confused with those of the site.) Your user name will be shown correctly but you will need to fill
in your password.
Database Connection String: The database connection that will be used after the site is
published. Note that this value is not stored in the project file “appsettings.json”, which stores
the “Default Connection” to the local database.
For more details on how to find your database connection string
4. Publish the Project
Right-click on the project name in the VS Solution Explorer and select Publish from the context
menu.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
5 de 14 01/02/2022 12:11 p. m.
6.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
6 de 14 01/02/2022 12:11 p. m.
7.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
7 de 14 01/02/2022 12:11 p. m.
8.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
8 de 14 01/02/2022 12:11 p. m.
9.
Enter the real password and check "Save password", click "Validate connection" button, in the
upcoming window, click "Accept".
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
9 de 14 01/02/2022 12:11 p. m.
10.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
10 de 14 01/02/2022 12:11 p. m.
11.
Press the Next button to get to the second screen.
On the second screen, accept default values:
Configuration: Release
Target Framework: net5.0
Deployment Mode: Framework-Dependent Note: you can choose 'Self-Contained' if the core
version is not installed on the server.
Target Runtime: Portable
Expand the lists on the second screen and check all of the boxes on both screens. Note that VS
may fill in the database field(s) with the local connection. This is incorrect; both the Databases
and the Entity Framework Migrations text fields should contain the path to the database on the
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
11 de 14 01/02/2022 12:11 p. m.
12. server, as you got from step #3.
If you get the error "ERROR_CERTIFICATE_VALIDATION_FAILED", please re-validate the connection in
the previous captured "Publish Connection" window, or add the following line in .pubxml file.
<AllowUntrustedCertificate>true</AllowUntrustedCertificate>
If you want to set value of ASPNETCORE_ENVIRONMENT while deploying, please add the following
line in .pubxml file.
<EnvironmentName>Production</EnvironmentName>
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
12 de 14 01/02/2022 12:11 p. m.
13.
Once you have created a profile you can reuse it every time that you publish by simply running the
Publish command.
Observer the Output window in VS to see if the publication worked properly.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
13 de 14 01/02/2022 12:11 p. m.
14. Article ID: 2135, Created: abril 8, 2021 at 01:53 a. m., Modified: abril 14, 2021 at 08:38 p. m.
How to publish ASP.NET Core web application via Visual Studio 2019 https://www.smarterasp.net/support/kb/a2135/how-to-publish-asp_net-co...
14 de 14 01/02/2022 12:11 p. m.