I'm using the SharePoint Online CSOM library to access different SharePoint servers. I want to be able to determine whether the server I am connecting to is SharePoint Online or an on-prem server.
I have seen some answers suggesting to check the web response header where the SharePoint version is returned, but I don't think that is a good solution since SharePoint 2016 on-prem is now released.
I've also seen a suggestion to check the
tenantAppVersion in the
_spPageContextInfo object, but I'm using C# and have not found a way to get access to anything like that.
Some have also suggested to check if ".sharepoint.com" is part of the domain name, but that doesn't work for custom domain names. So, how can this be done programmatically?