【问题标题】:How to determine the correct (case sensitive) URL for a SharePoint site如何确定 SharePoint 网站的正确(区分大小写)URL
【发布时间】:2011-01-28 09:07:50
【问题描述】:

问题: 使用 SharePoint API(对象模型)在 SPSite 或 SPWeb 对象的 URL 中大小写不正确的情况下创建网站栏将导致新栏在尝试编辑时引发异常它是通过网站专栏库制作的。

SharePoint 通常非常容忍以不区分大小写的方式接受 URL,但是在少数情况下它会完全崩溃。例如,在创建站点栏时,它以某种方式存储和使用创建时的 URL,当尝试通过站点栏库(布局中的 fldedit.aspx 页面)编辑字段定义时,您最终会抛出以下错误。

Value does not fall within the expected range.
at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName, Boolean bThrowException)
at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName) 
at Microsoft.SharePoint.ApplicationPages.BasicFieldEditPage.OnLoad(EventArgs e) 
at System.Web.UI.Control.LoadRecursive() 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

如何可靠地获取站点/网站的正确 URL? SPSite.Url 和 SPWeb.Url 属性似乎会返回它们被实例化的任何情况。

换句话说,网站集是使用以下 URL 配置的:http://server/Path/Site

然后,如果我使用 SharePoint 对象模型创建一个新的网站栏,并且在实例化 SPSite 和 SPWeb 对象时碰巧使用了http://server/path/site,则该网站栏将可用,但在尝试通过库访问它时出现错误上面是生成的。如果我更正地址栏中的 URL,我仍然可以查看/修改相关 SPField 的定义,但生成的默认 URL 是伪造的。

清如泥?

示例代码:(由于区分大小写问题,这是一个不好的示例)

// note: site should be partially caps: http://server/Path/Site
using (SPSite site = new SPSite("http://server/path/site")) {
  using (SPWeb web = site.OpenWeb()) {
    web.Fields.AddFieldAsXml("..."); // correct XML really here
  }
}

【问题讨论】:

  • 您在哪里运行创建网站栏的代码?通过特征接收器?
  • @UnhipGlint 我目前只是在服务器上的控制台应用程序中运行它。最终它可能会在功能接收器或服务器控件/.ashx 中被按需调用。

标签: sharepoint moss wss


【解决方案1】:

不确定这是否会影响您,但在 SharePoint url 中存在一个关于区分大小写的已知错误。

http://blogs.msdn.com/enterprisesearch/archive/2008/01/25/crawling-case-sensitive-web-content-in-sharepoint-server-2007-and-search-server-2008.aspx

由于您是在 3 月发布此内容,因此您可能有一个安装了修补程序的服务包。但是,您可能缺少注册表设置。

【讨论】:

  • 这个很好知道,可惜好像没有解决网站栏的具体情况。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-11-19
  • 2016-01-07
  • 1970-01-01
  • 2014-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多