SPWeb.File.Add() it throws "The server instance not found" error message

PROBLEM

When we use the FQDN name in the SPWeb object, and calls the Add() method, we will get the following error message.

The server instance not found

Root Cause:

In stsadm.exe or any executable, STS only uses the IIS metabase to figure out the IIS instance for a given URL. For SSL, the IIS metabase only contains IP and port information and there is no host-header or fully qualified domain name information. If we try to use new SPSite(https://xxxxx.xxxxx.xxxxxx.microsoft.com) we cannot find the IIS instance because karthickmain.fareast.corp.microsoft.com is not in the SSL entry in the IIS metabase.

Resolution:

The issue was caused by the use of a service user identity in the format of user@domain.com rather than domain\user. This service user identity syntax works as long as the code uses the FQDN but not if the code is using the machine name. In stsadm.exe or any executable, STS only uses the IIS metabase to figure out the IIS instance for a given URL. For SSL, the IIS metabase only contains IP and port information and there is no host-header or fully qualified domain name information. If we try to use new SPSite(https://xxxxxxxx.xxxxxx.microsoft.com) we cannot find the IIS instance because karthickmain.fareast.corp.microsoft.com is not in the SSL entry in the IIS metabase. WORK AROUND: Use IP address (or) machine name instead of the fully qualified domain name (FQDN), for example, SPSite site = new SPSite("https://172.26.232.190");