从主页 Web 部件访问 MySite 博客

发布于 2024-09-28 17:09:52 字数 599 浏览 2 评论 0原文

我已经离开 SharePoint 开发很长一段时间了,我正在尝试从 C# Web 部件访问 SharePoint 2010 博客中的信息(来自我们的一位用户,在他们的“MySite”中),该部件将驻留在网站的主页。这个想法是能够在主页上突出显示某个用户的最新帖子。

任何人都可以帮助我参考该博客(在开发中,它位于 http://myServer/my/BillsBlog)从我们的主页。我已经尝试过以下操作...

  • 引用将 URL 作为构造函数参数的 SPSite,然后从那里获取正确的 Web。这失败了。 (我猜博客是一个网络,而不是网站集,但我愿意在那里进行更正)
  • 从 SPContext.Current 获取当前上下文,并从那里访问 AllWebs 集合,但这不包括 /我的网。

一旦找到合适的容器(SPSite 或 SPWeb),我就可以访问列表以提取我需要的项目,但我不知道如何到达这一点。在控制台应用程序中,我使用上面第一个项目符号中的方法使其工作。

我现在真的很困惑,我根本不知道自己在寻找什么,无法在谷歌上搜索答案。您能给我的任何帮助将不胜感激。

I've been away from SharePoint development for quite a while now, and I'm trying to access the information in a SharePoint 2010 blog (from one of our users, within their "MySite") from a C# webpart which will reside on the homepage of the site. The idea is to be able to highlight a certain user's latest post on the home page.

Can anyone help me to reference the blog (in dev it is located at http://myServer/my/BillsBlog) from our homepage. I've tried the following...

  • Reference an SPSite giving the URL as a constructor parameter, then get the correct web from there. This fails. (I'm guessing the blog is a web, rather than a site collection, but am open to being corrected there)
  • Get the current context from SPContext.Current, and access the AllWebs collection from there, but this doesn't inculde the /my web.

Once I find the appropriate container (SPSite or SPWeb) I can access the list to pull out the items I need, but I don't know how to get to that point. In a console App, I have it working by using the method in the first bullet abouve.

I'm really pretty much stuck now, and I simply don't know enough about what I'm looking fro to be able to search Google for answers. Any help you could give me would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画中仙 2024-10-05 17:09:52

好吧,我的错。 Webpart 项目被设置为沙盒项目,因此第 1 条中的方法不起作用。更改该开关意味着它现在可以正常工作并且可以按照控制台应用程序运行。

感谢您的阅读。

OK, my mistake. The webpart project was set up as a sandboxed one, so the approach in bullet 1 wouldn't work. Changing that switch meant it is now OK and working as per the console app.

Thanks for reading.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文