根据 GUID 获取站点 URL?(SharePoint) [英] Get site URL based on GUID? (SharePoint)

查看:67
本文介绍了根据 GUID 获取站点 URL?(SharePoint)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我知道 guid,是否有任何代码示例向我展示如何获取站点的 url?

is there any code example out there that shows me how to get the url for a site if I know the guid?

目前我有这个代码来获取网站集中的所有网站.

Currently I have this code to get all sites within the site collection.

private void getSites()
{
    SPSite oSiteCollection = SPContext.Current.Site;
    SPWebCollection collWebsite = oSiteCollection.AllWebs;
    for (int i = 0; i < collWebsite.Count; i++)
    {
        ddlParentSite.Items.Add(new ListItem(collWebsite[i].Title, collWebsite[i].ID.ToString()));
    }
}

提前致谢.

推荐答案

SPSite 有一个 GUID 构造函数

SPSite has a GUID constructor

using(SPSite site = new SPSite(guid)) {
    return site.Url;
}

而且 SPSite 有一个 OpenWeb(GUID) 方法

And SPSite has a OpenWeb(GUID) method

using(SPSite site = new SPSite("http://somesite")) {
    using (SPWeb web = site.OpenWeb(guid)) {
        return web.Url;
    }
}

这篇关于根据 GUID 获取站点 URL?(SharePoint)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆