首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在SharePoint 2010中以编程方式创建wiki站点时设置URL?

如何在SharePoint 2010中以编程方式创建wiki站点时设置URL?
EN

Stack Overflow用户
提问于 2011-02-01 22:23:51
回答 2查看 1.7K关注 0票数 0

我正在创建一个新的网站:

代码语言:javascript
运行
复制
SPSite currentContext = SPContext.GetContext(HttpContext.Current).Site;
SPWeb parentID = currentContext.OpenWeb(new Guid(parentSiteValue));

newWeb = parentID.Webs.Add(newSiteUrl, newSiteName, null, (uint)1033, siteTemplate, true, false);

siteTemplate是我在下拉列表中选择的模板,当我从团队站点模板或相似的站点创建站点时,创建站点很好,但是当创建wiki站点时,父站点下的实际URL是/pages/ have . as,但是如果我将它添加到newSiteUrl中,就会得到错误,例如不能使用拖尾斜杠,文件夹不存在等等。

如何创建一个wiki站点并以编程方式设置url?

提前谢谢。

编辑将URL设置为newSiteUrl = newSiteName + "/pages/“给我

代码语言:javascript
运行
复制
"testpage/pages/" contains leading or trailing slash, which is invalid.

newSiteUrl = newSiteName + "/pages“

代码语言:javascript
运行
复制
The folder that would hold URL '/dept/class/wikitest/pages' 
does not exist on the server.

newSiteUrl = newSiteName +“/pages/pages.pages”

代码语言:javascript
运行
复制
The URL '/dept/class/wikitest/pages/home.aspx' is invalid. 
It may refer to a nonexistent file or folder, 
or refer to a valid file or folder that is not in the current Web.
EN

回答 2

Stack Overflow用户

发布于 2011-02-01 23:51:52

我在这里贴出了你的问题的答案:http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/e25f10ef-bdd9-4445-8508-67b58c2396f9,希望这能帮上忙!

乔尔

joelblogs.co.uk

票数 0
EN

Stack Overflow用户

发布于 2011-02-02 05:26:06

您可以这样设置url:

代码语言:javascript
运行
复制
using (SPSite site = new SPSite("http://localhost"))
{
    string parentWebName = "MyOrganization";
    using (SPWeb parentWeb = site.OpenWeb())
    {
        string webTitle = "DepartMent Wiki";
        string webDesc = "DepartMent Wiki";     string webName = "HRWiki";
        string webUrl = String.Format("{0}/{1}", parentWebName, webName);
        uint webLcid = parentWeb.Language;

        // Name value for the Document Workspace template.
        string webTemplateName = "STS#4";

        SPWeb newWeb = null;

        // Create the new web.
        try
        {
            newWeb = site.AllWebs.Add(webUrl, webTitle, webDesc, webLcid, webTemplateName, false, false);

            SPFolder rootFolder = newWeb.RootFolder; 
            rootFolder.WelcomePage = "My Wiki Library/MyWelcome.aspx";
            rootFolder.Update();
        }
        catch (ArgumentException ex)
        {
        }
    }
}

希望能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4868658

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档