I came across very peculiar issue when I was trying to create SharePoint 2013 Project in Visual Studio 2012 while connecting to my SSL enabled SharePoint Sites. Visual Studio thrown an error – cannot connect to the targeted site. This error can occur if the specified site is not hosted on the local system.
Since I am working on all-up VM with AD, DC, DNS, CA, SQL, SharePoint, Office, SPD, and Visual Studio all runs on same machine, obviously issue was with the method of how Visual Studio trying to connect to the SharePoint. As you can see in the DNS entries below, https://intranet.niks.local (the site I am trying to specify as debug site in Visual Studio) pointing to the correct IP (192.168.1.31) mapped to the local host.
After doing some quick research on google, apparently it seems like this issue was introduced in Visual Studio 2012 RC and how VS connects to the SharePoint using host file entries (not DNS entries) to recognize host header enabled SharePoint sites. As soon as I read Waldek‘s article, I knew where was the problem.
I was able to connect to the my Non-SSL SharePoint sites from Visual Studio 2012 up until last week. I was using hosts files to route all the URL requests to the host header enabled Non-SSL SharePoint sites. After configuring SSL this week on my local SharePoint environment, I have cleaned up all the host file entries to ensure all the URL routes through DNS.
Since Visual Studio uses hosts files to connect to the SharePoint sites, it would make sense why it was working for Non-SSL sites (with host file entries) and why it wasn’t working with SSL sites (without host file entries). As soon as I have updated host files to route SharePoint host header enabled sites, Visual Studio was able to connect to the SharePoint site while creating new projects.
Thanks to thousands of references out there in Google, I was able to quickly save some time for me.
- Cannot connect to the targeted site error in Visual Studio 2012 SharePoint Developer Tools when working with custom host headers – http://www.malneedinani.com/2013/05/cannot-connect-to-targeted-site-error.html
- ‘Cannot connect to the targeted site’ error in Visual Studio 2012 RC SharePoint Developer Tools when working with custom host headers – http://blog.mastykarz.nl/cannot-connect-to-the-targeted-site-error-visual-studio-2012-rc-sharepoint-developer-tools-host-headers/