gpt4 book ai didi

SharePoint:SPContext.Current 在 SharePoint Foundation 2010 中返回 null

转载 作者:行者123 更新时间:2023-12-01 12:57:48 26 4
gpt4 key购买 nike

我正在使用以下代码从 Sharepoint 访问 Web 应用程序。

SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

它适用于共享点 server 2010(MOSS2010)。但是当我使用 SharePoint foundation 2010(WSS4.0) 时,SPContext.Current 总是返回 null。谁能告诉我这可能是什么原因?我该如何解决这个问题?

感谢和问候,莎米拉

最佳答案

我发现 SPContext 为空的常见原因之一是您的 AAM 配置不正确。 Sharepoint 了解为您的站点配置了哪些 URL 非常重要,因为如果您的 URL 未注册,它无法判断该 URL 是否在 SPContext 中,因此创建它。

The most common change Ive seen is modifying the host headers of the IIS site. This is an enormous no-no, please don't ever do this (use AAM's instead). If you do go ahead and modify these any of your newly added headers will only be partly functional. Inside of SharePoint there is a lot of components which rely directly on the URL and in particular on looking this URL up internally. What you find (for the developers) is that references to SPContext.Current (a core piece of SharePoint goodness) will not work. This causes havoc on random SharePoint pages, web parts and custom features.

如果您想了解如何设置 AAM(并了解它们为何如此重要),请查看此处查看我关于该主题的博客文章 http://blog.staticvoid.co.nz/2011/05/sharepoint-alternate-access-mappings.html

关于SharePoint:SPContext.Current 在 SharePoint Foundation 2010 中返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8725255/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com