I have been trying to get my MVC C# code to connect to my sharepoint server. I have tried everything and I keep getting this error no matter what I try.
The Web application at [http://myserver/] could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
This is my code:
string strUrl = "http://myserver/";
using (SPSite site = new SPSite(strUrl))
{
}
Note that SPSite/SPWeb only work on a Server that has SharePoint installed and is part of the Farm. It may work on non-Sharepoint machines, but this is officially unsupported and certain operations may throw exceptions.
Generally, external connectivity to SharePoint is done through Web Services or (since 2010) through the Client Object Model.