简体   繁体   中英

how to find the url to connect SharePoint with C# console application

My C# console application is built on SharePoint Server 2007. My job is to select all items in the library from a SharePoint site. However, I cannot connect my app with a SharePoint site's SPSite object...

My code to connect SharePoint site:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;

namespace TryToConnect
{
    class Program
    {
        static void Main(string[] args)
        {
           string siteurl = "http://sp13vm123/";
         //string siteurl = "http://sp13vm123/imgLibrary/Forms/AllItems.aspx";
         //string siteurl = "http://sp13vm123/imgLibrary/";
         //string siteurl = "http://sp13vm123:8800/";
         //string siteurl = "http://sp13vm123/SitePages/Home.aspx";
         //string siteurl = "http://sp13vm123/SitePages/";


            SPSite oSpSite = new SPSite(siteurl );
            Console.WriteLine("connected");//nothing
        }
    }
}

There is an error message about URL cannot found...

So, how can I find the URL to let me connect?

The URL of SharePoint central Administration? error, not found

The URL of Layout Page? error, not found

In SharePoint 2007, you can only use SPSite objects (and any other objects from the SharePoint object model) when your code is executed from a web server on the SharePoint farm.

If you're running it from any other location, it will not have access to the SharePoint object model, and you'll need to use another approach (such as SharePoint's SOAP-based web services ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM