2016-08-24 40 views
0

我的C#控制檯應用程序構建於SharePoint Server 2007上。我的工作是從SharePoint網站中選擇庫中的所有項目。然而,我無法將應用程序與SharePoint網站的SPSite對象連接...如何查找將SharePoint與C#控制檯應用程序連接的URL

我的代碼來連接SharePoint網站:

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 
     } 
    } 
} 

有無法找到關於網址的錯誤訊息...

那麼,如何找到讓我連接的URL?

SharePoint中央管理的URL?錯誤,未找到

佈局頁面的URL?錯誤,未找到

+0

@rene所以,我可以在客戶端模式下連接的URL是什麼? –

+0

@Rene正如國王所說的「C#控制檯應用程序建立在SharePoint服務器2007上」,你真的認爲他需要使用CSOM –

+0

@king如果你的控制檯應用程序在SharePoint服務器上,那麼你不需要用戶CSOM但如果你是在遠程服務器上,那麼你需要使用csom –

回答

0

在SharePoint 2007中,只有在SharePoint場中的Web服務器上執行代碼時,才能使用SPSite對象(以及來自SharePoint對象模型的任何其他對象)。

如果您從任何其他位置運行它,它將無法訪問SharePoint對象模型,並且需要使用其他方法(例如SharePoint's SOAP-based web services)。

+0

我的項目在SharePoint服務器上運行,但它總是說:「http:// sp13vm123 /上的Web應用程序無法找到。請確認您輸入的URL是否正確。如果URL應該提供現有內容,系統管理員可能需要添加一個新的請求URL映射到預期的應用程序。「因此,我發佈這個問題,什麼是連接正確的URL .. –

+0

但當你拉起服務器上的Web瀏覽器,並導航到「http:// sp13vm123」它正確加載SharePoint網站? – Thriggle

+0

是的,是的。所以我不知道是什麼問題。它會有任何權限問題嗎? –

相關問題