本文介绍了SharePoint CSOM“操作已超时";在循环创建网站集的多页URL上下文时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要访问或获取网站集中页面的文件信息,页面可以位于根站点或任何子站点.为了实现这一点,我们在"foreach"循环中创建站点的上下文,以获取有关页面的信息(有效或无效).但是之后 两个页面URL,我们将得到 操作已超时" 例外.

We need to access or get file information for the pages in a site collection, page can be at root site or any sub site. In order to achieve this we are creating context of site in "foreach" loop to get information about the page (valid or not). But after two page URLs we are getting "The operation has timed out" exception.

在这方面的任何帮助都会有很大帮助.

Any help in this regard will be a great help.

我们尝试过的方法:

1.同步调用以创建单个页面的上下文

1. Synchronous call to create context for individual pages

2.异步调用为单个页面创建上下文

2. Asynchronous calls to create context for individual pages

3.增加请求超时时间

3. Increase request time out time

4.使用两个不同的用户登录名创建备用上下文

4. Creating alternate context with two different user logins

5.通过从网站集上下文中获取子网站上下文(它适用于直接子网站,但不适用于任何子网站的子网站)

5. By fetching child site context from site collection context (it works for direct child sites but not for sub site of any sub site)

for(int i = 0; i< arrPageUrlMapping.GetLength(0); i ++)

for (int i = 0; i < arrPageUrlMapping.GetLength(0); i++)

{

               Uri fileUrl =新Uri(arrPageUrlMapping [i,1]);

                Uri fileUrl = new Uri(arrPageUrlMapping[i, 1]);

               ClientContext olClientcontext = null;

                ClientContext olClientcontext = null;

              尝试

                try

               {

                {

              b ;       olClientcontext = new ClientContext(contextUrl);

                                olClientcontext = new ClientContext(contextUrl);

              b ;       olClientcontext.Credentials =新的SharePointOnlineCredentials(_AuthenticateOnline.userName, _AuthenticateOnline.password);

                                olClientcontext.Credentials = new SharePointOnlineCredentials(_AuthenticateOnline.userName, _AuthenticateOnline.password);

              b ;       olClientcontext.Load(olClientcontext.Web);

                                olClientcontext.Load(olClientcontext.Web);

              b ;       olClientcontext.Load(olClientcontext.Web.Webs);

                                olClientcontext.Load(olClientcontext.Web.Webs);

              b ;       olClientcontext.Load(olClientcontext.Site);

                                olClientcontext.Load(olClientcontext.Site);

              b ;       olClientcontext.ExecuteQuery(); //此行 抛出异常

                                olClientcontext.ExecuteQuery(); //this line throw exceptions

              b ;      

                               

              b ;       FileInformation fileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(olClientcontext, fileUrl.LocalPath);

                                FileInformation fileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(olClientcontext, fileUrl.LocalPath);

               }

                }

              捕获(异常除外)

                catch (Exception ex)

               {

                {

              b ;       base.objLogging.logError(例如消息,HelperClass.logging.DiagnosticsCategory.Error, ",,");

                                base.objLogging.logError(ex.Message, HelperClass.logging.DiagnosticsCategory.Error, "", "");

               }

                }

              终于

                finally

               {

                {

              b ;       olClientcontext.Dispose();

                                olClientcontext.Dispose();

               }

                }

}

推荐答案

从线程的描述来看,您的问题似乎与SharePoint有关.

From the description of the thread, it looks like your issue is related with SharePoint.

此论坛仅处理有关App for Office Development的问题.

This forum only handles the issue regarding App for Office Development.

因此,为了更好地响应您的问题并提供更好的解决方案,我将该线程移至 SharePoint 2013开发论坛.

So for better response and better solution for your issue, I move this thread toSharePoint 2013 development Forum.

我们建议适当发布的原因是,您将获得最合格的受访者群体,而定期阅读论坛的其他合作伙伴可以分享他们的知识或从您与我们的互动中学习.

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

谢谢您的理解.

关于

Deepak


这篇关于SharePoint CSOM“操作已超时";在循环创建网站集的多页URL上下文时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 09:06