This article is a mirror article of machine translation, please click here to jump to the original article.

View: 32993|Reply: 0

[Source] Publish your project to a remote IIS server using VS 2019

[Copy link]
Posted on 10/9/2020 12:09:22 PM | | | |
In the past, when publishing projects, files were copied and pasted to the site directory, or uploaded to the site directory through FTP, but now with the emergence of continuous integration, automated operation and maintenance, and automated publishing, publishing projects are also changing with each passing day.

This article describes how to publish remotely to a remote IIS site via VS 2019.

Remote Server System: Windows Server 2019 64-bit

Server configuration

1. Add IIS, install .NET framework (omitted)

2. Download and install Web Deploy

Web Deploy can be used to deploy web projects locally and remotely at the following address:The hyperlink login is visible.



At the time of installation, select"Complete"After installation, you will see the "Web Management Service" service in the service, as shown in the figure below:



If it is not installed, VS will get the following error when remotely publishing:

---------------------------
Microsoft Visual Studio
---------------------------
Failed to connect to the remote computer ("xx"). Make sure that Web Deploy is installed on the remote machine and the required process ("Web Management Service") is started.  Learn more at:https://go.microsoft.com/fwlink/ ... ATION_NOT_REACHABLE。 Unable to connect to remote servers
---------------------------
Are you sure   
---------------------------


3. Install "IIS Management Scripts and Tools"

Go to Select Server Roles > Web Server (IIS) > Administrative Tools, then select the IIS Administrative Scripts and Tools role, click Next, and install the role.



4. IIS enables remote connections

Locate the management service in IIS and enable remote connections, as shown in the following image:





(Note:Open the 8172 inbound port in the firewall and security group

5. Create a new IIS site

Create a new site named test1, as shown in the following figure:



6. IIS adds administrative users

Add an IIS Manager user, as shown in the following image:



At the same time, on the test1 site, add authorization, as shown in the figure below:



If you do not add authorization, the following error will be reported when you publish remotely:

---------------------------
Microsoft Visual Studio
---------------------------
You have connected to a remote computer ("xxx") using the web management service, but have failed to authorize it. Make sure that you use the correct username and password, that the site you are connected to already exists, and that the user whose credentials represent has access to the site.  Learn more at:https://go.microsoft.com/fwlink/ ... R_USER_UNAUTHORIZED。 The remote server returns an error: (401) Unauthorized.
---------------------------
Are you sure   
---------------------------
Release ASP.NET MVC project

First, create a new .NET 4.6.2 asp.net mvc project with the name WebAutomatedDeployment using VS 2019,

Create two new libraries, and the website program references these two libraries at the same time. (Create and reference 2 libraries because the simulation is closer to the official project)


Try starting the project as shown below:



Right-click the project, select Publish, Web Server (IIS)-> Web Deployment, and fill in the server information, as shown in the following figure:



Verify the connection and the test passes, as shown in the following image:



When I tried to publish, the error was as follows:

The web deployment task failed. ((2020/10/9 11:34:38) Error processing request on remote computer. )

(2020/10/9 11:34:38) Error processing request on remote computer.
The server is having trouble processing the request. Contact your server administrator for details.        WebAutomatedDeployment                0
You can view specific errors through the Server Event Viewer, as shown in the following figure:



User: itsvse
Client IP: xxx
Content-Type: application/msdeploy
Version: 9.0.0.0
MSDeploy.VersionMin: 7.1.600.0
MSDeploy.VersionMax: 9.0.3802.0
MSDeploy.Method: Sync
MSDeploy.RequestId: def8d9f7-1a72-4b19-8b75-919f8c6a9604
MSDeploy.RequestCulture: zh-CN
MSDeploy.RequestUICulture: zh-CN
ServerVersion: 9.0.1973.0
Skip: objectName="^configProtectedData$"
Provider: auto, Path:
A trace deployment agent exception propagated to the client occurred. Request ID "def8d9f7-1a72-4b19-8b75-919f8c6a9604", request timestamp: "2020/10/9 11:51:29". Error details:
System.UnauthorizedAccessException: 尝试执行未经授权的操作。
   In System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
   In System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)
   at Microsoft.Web.Deployment.FileSystemSecurityEx.Persist(String path, Boolean isFile)
   at Microsoft.Web.Deployment.SetAclProvider.Add(DeploymentObject source, Boolean whatIf)
   at Microsoft.Web.Deployment.DeploymentObject.Update(DeploymentObject source, DeploymentSyncContext syncContext)
   at Microsoft.Web.Deployment.DeploymentSyncContext.HandleUpdate(DeploymentObject destObject, DeploymentObject sourceObject)
   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
   at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
   In Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId, String syncSessionId)
   at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable'1 passId, String user, String siteName)
   at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)
   at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)
Solution:

Restart VS Tools, click Publish, and the following image will pop up:



Check "Save this certificate for future sessions in Visual Studia" can be solved.

The first time it was published, it was slow because all the files needed to be uploaded to the server, as shown in the figure below:



Try to modify the Index.cshtml page file and click Republish, only the following 3 files will be updated, as shown in the figure below:



Refresh the website and find that it has been updated, as shown below:



(End)




Previous:Build an ocserv vpn proxy on CentOS 7
Next:Aspose.Cells Three Musketeers
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com