visual-studioiiswindows-serverweb-publishing

"The Local Security Authority Cannot be contacted" error when trying to web-publish from visual studio


I'm trying to web publish a project from Visual Studio 2022 at IIS10 on a remote Windows Server 2019. In .pubxml, MSDeploy is specified as the Web Publish Method. And in this situation I get the following error:

Could not complete the request to remote agent URL 'https://XX.XXX.XXX.XX:YYYY/msdeploy.axd?site=site_example'. The underlying connection was closed: An unexpected error occurred on a receive. The decryption operation failed, see inner exception. Local Security Authority cannot be contacted. Publish failed to deploy.

Access to the server is open on the port XX.XXX.XXX.XX:YYYY and accessible via RDP. I looked for how to configure a server for web publishing on various resources. Maybe I didn't configure something?


Solution

  • The underlying connection was closed: An unexpected error occurred on a receive.

    First of all, make sure you have set the Service Point Security Protocol type the same as your target server. For example, add code below:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    

    The decryption operation failed, see inner exception. Local Security Authority cannot be contacted. Publish failed to deploy.

    Secondly, you can check whether the user account permissions are sufficient for you to publish the application. You may also need to check the Local Security Policy settings on the remote server to ensure that the necessary permissions are granted.

    If the above doesn't work for you, you can also try publishing via the command line, for example:

    msdeploy.exe -verb:sync -source:contentPath='<path-to-project-directory>' -dest:contentPath='<destination-url>',computerName='https://<remote-server-name>:8172/msdeploy.axd?site=<site-name>',userName='<username>',password='<password>',authType='Basic'