我正在尝试获取给定sharepoint网址的GUID。我不介意使用API或webservices或Sharepoint的数据库。
如果我要编写一个函数,它的签名将是: //从路径获取GUID。 string GetGuidFromPath(string path){}
我有一个领导:SPContentMapProvider但它似乎没有得到正确的信息。
谢谢!
答案 0 :(得分:1)
取决于 - 当前请求的上下文是什么?您的代码是否在SharePoint请求的上下文中运行?如果是这样,您可以使用SPContext.Current.Web.ID
否则,您的代码是否至少在其中一台SharePoint服务器上运行?如果是这样,您将需要使用:
// Given the URL http://mysharepointsite.com/sites/somesite/somesubsite
using(SPSite site = new SPSite("http://mysharepointsite.com/sites/somesite"))
{
using(SPWeb web = site.OpenWeb("somesubsite"))
{
Guid webId = web.ID;
}
// Or
Guid rootWebId = site.RootWeb.ID;
}