【发布时间】:2015-12-18 09:14:14
【问题描述】:
我必须使用 CSOM 打印共享点站点下的子网站列表。 我使用了这段代码和我的服务器凭据,但我在 foreach 循环的第二行进入了一个无限循环。 该行是
getSubWebs(newpath);
static string mainpath = "http://triad102:1001";
static void Main(string[] args)
{
getSubWebs(mainpath);
Console.Read();
}
public static void getSubWebs(string path)
{
try
{
ClientContext clientContext = new ClientContext( path );
Web oWebsite = clientContext.Web;
clientContext.Load(oWebsite, website => website.Webs, website => website.Title);
clientContext.ExecuteQuery();
foreach (Web orWebsite in oWebsite.Webs)
{
string newpath = mainpath + orWebsite.ServerRelativeUrl;
getSubWebs(newpath);
Console.WriteLine(newpath + "\n" + orWebsite.Title );
}
}
catch (Exception ex)
{
}
}
要检索子网站需要更改哪些代码?
【问题讨论】:
-
你收到
StackOverflowException了吗?
标签: c# timeout sharepoint-2013 csom request-timed-out