Monday, May 13, 2013

Cannot connect to the targeted site error in Visual Studio 2012 SharePoint Developer Tools when working with custom host headers

When I am working with the new Visual Studio 2012 RC SharePoint Developer Tools I get the ‘Cannot connect to the targeted site’ error message if I try to connect to a local site that is using a host header.

Cannot connect to the targeted site. This error can occur if the specified site is not hosted on the local system. SharePoint solutions work only with locally-installed versions of SharePoint Foundation or SharePoint Server. Remote development is supported only for apps for SharePoint 2013.

Do like this :registered the site URL in DNS (local DNS on development machine) then you’ll get this error. It seems that Visual Studio looks at the hosts file
(C:\Windows\system32\drivers\etc\hosts) for fully qualified names instead of DNS.

Once you add the site’s URL to the hosts file (either to or the local IP of the development machine) all is good and Visual Studio will connect .

Hope this one helps!