Remotely publish ASP.NET Core programs to IIS Web servers on the Internet
- Windows Server
- Windows Server 2019
- Internet Information Services (IIS)
- ASP.NET Core
- Web Deploy
- 3.6 Japanese version
Learn how to upload ASP.NET Core programs directly from Visual Studio to Internet Information Services (IIS) that you set up on Windows Server.
The first time you need to work on Windows Server, once you set it up, you can publish it directly from Visual Studio for the second time and beyond.
This Tips publishes programs to servers on the Internet, but security measures are minimal, so if you are worried, we recommend that you take additional measures or take another upload method.
- Windows Server set up
- You already have a ASP.NET Core program to upload
- Connect to servers over the Internet or intranet
Set up Internet Information Services (IIS)
The steps are summarized on the following page. IIS can also be used for other than running ASP.NET Core programs.
By the way, additional settings are required in iis setup, but it is not set in tips linked above. You can set it up later, so we'll talk about that later.
Add management services in IIS
Add it because the default IIS setup does not set up a "managed service".
Start Server Manager.
From manage the menu, select Add Roles and Features.
Press the "Next" button several times to the desired screen.
When you come to the "Select Server Role" screen, expand "Web Server (IIS)" and "Management Tools" and check "Management Services". (The figure is in English, but it is the same.)
If ASP.NET 4.7 is not installed, the following dialog will appear, so add it together.
After that, please click the "Next" button as it is and install it.
When you open IIS Manager, you can verify that administrative services have been added.
The firewall also automatically allows ports for deployment.
installing ASP.NET Core Hosting Bundle
Required to run ASP.NET Core on Windows Server. Once installed, it can work in IIS like a traditional ASP.NET application.
Go to the following pages: By the way, this Tips uses 5.0, so if you use a different version, go to the corresponding page.
There is a Hosting Bundle for Windows at runtime at the bottom right of the screen, so click the link to download it.
Run the downloaded installer on Windows Server.
Close when the installation is complete.
Installing Web Deploy
Required to receive a publishing program from Visual Studio.
Go to the link below.
Windows Server has only a basic 64-bit version, so download the 64-bit version.
Run on Windows Server.
Check "I accept the license agreement" and click "Next".
Click the "Install" button.
When the installation is finished, click the "Done" button.
When you open IIS Manager, you've added Delegate Management Services.
Application pool settings
For ASP.NET Core, the .NET CLR is irrelevant, so add an application pool without managed code. You can safely change the existing DefaultAppPool. This setting is not directly related to web deployment, so I will not take care of the details.
If you added an application pool, set it to the site.
Create a site
Create a site. You can create a new one, or you can use the Default Web Site from scratch. This Tips will keep default Web Site. Site creation has nothing to do directly with web deployment, so I don't want to go into detail.
Create a deployment user
It can also be deployed in a Windows account, but it increases security risks and creates a dedicated deployment user. You do not need to configure this item if you are deploying in a Windows account.
Start IIS Manager.
Select a server from the left tree and open IIS Manager Users in the central Administration group.
Click Add User on the right.
Create by entering the name and password of the deployment user.
You only added users to IIS, so you need to set permissions for each site. This setting is not required if you are publishing with a Windows administrator account.
Select the site from the tree on the left to open IIS Manager Permissions.
From the right item, click Allow Users.
Since we specify the user that we added to IIS this time, check iis manager and click the select button. If you want to publish with a Windows account, check Windows.
A list of users is displayed, and you select it.
Once selected, click the OK button.
The state that was added.
Select a server from the tree on the left to open Management Services.
If "Enable remote connection" and "Windows credentials or IIS Manager credentials" are checked, you do not need to do anything. If you're publishing with a Windows account, it's OK if "Windows credentials only" is checked.
If it is not checked, check it.
I think that each item is in a state where you can not enter, so click "Stop" on the right.
Check the items you need. When you're done, click the "Start" link to the right.
There is a setting to increase security at the bottom of this screen, but first of all, it is necessary to confirm that it can be arranged, so I will not spare this time.
Deploying programs from Visual Studio
Return to your work PC and start Visual Studio to open the ASP.NET Core program. This time, we will publish a program with a new project created.
Right-click on the project and select Publish.
Select Web Server (IIS) and click Next.
Select Web Deployment.
Type the following:
|server||The IP address or DNS or domain name of the server that configured IIS. You can specify either the Internet or the intranet.|
|Site name||Specifies the site name that is added to IIS.|
|To URL||There is no problem with white space.|
|User name||Specifies the user account on Windows Server or the user name that you created in IIS.|
|password||Enter the authentication password for the user above.|
|Save password||If it is troublesome to enter a password every time you publish, save it.|
It is created as shown.
If you have created multiple publishing profiles, you can change them in the dropdown above, but if the name is confusing, you can do so.
Detailed settings can be changed on the edit screen.
"Settings" is selected from the left tab. You don't need to make any special changes, but change the Configuration, Target Runtime, and File Publishing Options as needed.
"Connect" is selected from the left tab. You will see what you typed first, but click on the "Verify Connection" button below.
The following dialog will be displayed when you can successfully connect to the publisher. Check Save this certificate for future sessions in Visual Studio and click the "I agree" button. If you save, this dialog will only be displayed for the first time.
If a check mark is displayed on the right side of the verification of the connection, it will be possible to connect normally.
By the way, if it fails, click the link to check the cause and take action depending on the cause.
Common causes include:
- The user name and password are incorrect.
- The IIS does not allow users. Once the investigation method is deployed by a Windows administrator.
- Tcp 8172 firewall is not allowed. Clouds such as Azure do not allow it on the cloud side.
- You do not have the Web Deployment tool installed "fully".
- Iis is missing. Please double check this Tips.
When you're done, from Solution Explorer, click Solution → Project → Properties → PublishProfiles expand and set the issue name ". pubxml", so it opens.
Project Add and save the following code in the >
When you are finished setting up, publish with the publish button.
If you publish successfully, you're done. It may fail occasionally, so in that case, please issue it again or verify the connection.
If you can access it in a web browser and see the ASP.NET Core program working, you're done.
- November 12, 2021 : Added description because .pubxml was needed from some time