簡體   English   中英

在Filepoint Online中使用文件管理器

[英]Using File manager with Sharepoint Online

我正在嘗試連接到SharePoint Online,以瀏覽SharePoint上的文件夾,並使圖像文件導入到sql表中。 無法通過文件管理器訪問它-路徑顯示為無效(如果我通過SharePoint瀏覽並輸入u / p-路徑可訪問且有效)

我已經設置了一個代碼,要求輸入用戶密碼(我自動獲得的用戶名),它似乎可以在線連接到SharePoint,但是當我在瀏覽器中鍵入路徑時-出現無效的路徑錯誤。

調用此代碼以傳遞u / p(在幕后):

 protected void ConnectShrpt_Click(object sender, EventArgs e) { String DocLibName = "Documents"; If ((HiddenPassw.Value != "") && (HiddenUserEmail.Value !="")) { ClientContext clientContext = new ClientContext(FolderImage); SharePointOnlineCredentials cred = new SharePointOnlineCredentials(HiddenUserEmail.Value, ConvertToSecureString(HiddenPassw.Value)); clientContext.Credentials = cred; List list = clientContext.Web.Lists.GetByTitle(DocLibName); clientContext.Load(list.RootFolder); clientContext.ExecuteQuery(); } }​ 

我沒有收到以上代碼的任何錯誤消息。 一旦我進入瀏覽器-使用asp:FileUpload-那就是當我得到錯誤消息,指出路徑不存在。 如果我在相同的瀏覽器中手動進入相同的位置並輸入u / p,則可以使用相同的FileUpload瀏覽到該位置。 我需要我的代碼才能自動連接到SharePoint Online。 PS FolderImage是SharePoint網站的URL。

更新! 雖然在開發人員環境中沒有錯誤,但是一旦將其部署到SharePoint Server IIS時,我在上面附帶的代碼中就會出現錯誤。

 [IOException: The handshake failed due to an unexpected packet format.] System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) +420 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +287 System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +357 System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) +203 System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +827 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +357 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +20 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +77 System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +1135 System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +60 System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) +105 System.Net.ConnectStream.WriteHeaders(Boolean async) +484 [WebException: The underlying connection was closed: An unexpected error occurred on a send.] System.Net.HttpWebRequest.GetResponse() +1518 Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetIdcrlHeader(Uri url, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest) +1129 Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, SecureString password, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest) +122 Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh, Boolean alwaysThrowOnFailure) +402 Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext context, HttpWebRequest request) +743 Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream() +68 Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate() +635 Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest() +104 Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() +1397 AIM_Central._Default.ConnectShrpt_Click(Object sender, EventArgs e) in Default.aspx.cs:4139 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +129 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +141 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4949 

檢查“ FolderImage ”變量的數據。

要傳遞ClientContext方法,您需要傳遞站點URL。

string webUrl = "https://tenant-name.sharepoint.com/sites/test/";
ClientContext clientContext  = new ClientContext(webUrl)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM