Visual Studio Publish / Web Deploy

Web deploy can be used to upload a site developed through Visual Studio to the web server.  Using web deploy can help avoid issues like missing assemblies that might occur when uploading a Visual Studio project via FTP.  Note that the steps below are for Visual Studio 2019.  Additional information relating to Deployment Mode in Core can be found at the bottom of the article.
 
 
Set up a publish profile
 
In Visual Studio, right click the project and select Publish from the menu.
 
 
 
 
Select Web Server (IIS) as the publish target then Next.
 
 
 
 
Select Web Deploy as the Specific Target then Next.





The web deploy connection settings required are
 
Server:  web###.discountasp.net (replace "web###" with the Server from DiscountASP Control Panel > Account Info / Edit > Web Deploy Publishing Information; see below)
Site name:  the website's domain name / deploy path (if deploying to a subdirectory, it is added to the site name; ie, domain.com/subdirectory)
User name:  Control Panel Login
Password:  Same as Control Panel Password
Destination URL:  optional and can be left blank; for visiting the site after successful deployment
 
If there is a database, click Next to set up the connection string.  If not, click Finish.
 
 
 
 
Web Deploy Publishing Information
 
The connection settings for Web Deploy can be downloaded at DiscountASP Control Panel > Account Info / Edit > Web Deploy Publishing Information.  You can use this .xml file and import the publishing settings instead of manually entering the information.  This will create 2 profiles, one for FTP and one for Web Deploy.  On Visual Studio 2022, it will create a 3rd profile (blank) which you can ignore.  You can select either one and enter your password to deploy.
 
 
 
 
Connection String
 
If a connection string is required for the deployed project, a DiscountASP database connection string can be found at DiscountASP Control Panel > MS SQL Manager > Manage (applicable database).  Note that the example Connection String does not contain the database password in plain text, so it will need to be updated after copying it to Visual Studio.  After adding the connection string, Save.
 
 
 
 
Publish
 
After saving the publish profile, the left pane in Visual Studio should update.  Click Publish to deploy the project to the web server.  If there is an error on publish, open a ticket with the Support Department and provide the error in case Web Management Service needs to be manually restarted.
 
 
 
 
Core Publish Settings

Deployment Mode is typically set to Framework-dependent for supported versions found on the following Knowledge Base Article.  Self-contained deployment is selected when a newer version of .NET has not yet been rolled out to a site's web server.  In some rare cases, Self-contained deployment will also be used to include dependencies for an otherwise supported version of .NET.

Target Runtime is best set to win-x86 to match the site's app pool, which defaults to 32-bit.  Portable causing compilation on app startup, which can impact performance for larger apps.
 
 

Core Hosting Model defaults to InProcess for deployed apps.  If attempting to run more than one app from a single app pool, all Core apps will need to be changed to OutofProcess (case insensitive).  The hosting model can be changed by updating the .csproj file (left click on the Project name in Visual Studio) and add the following to the PropertyGroup:

<AspNetCoreHostingModel>OutofProcess</AspNetCoreHostingModel>