SharePoint 2010 事件处理程序(接收器)无法在 MySites 网站集的个人网站上运行

发布于 2024-12-10 06:04:45 字数 398 浏览 0 评论 0原文

我在其自己的 Web 应用程序上设置了 SharePoint 2010 MySites。基础级别有标准网站集 http://site:80/

每个用户的个人网站位于托管 URL /personal/ 处。

我有一个工作事件处理程序,当用户将某些内容添加到图片库时,它会将项目添加到新闻源。

问题: 问题是,只有当它们添加到基础网站集 http://site:80/ 上的图片库时,这才有效,而如果它们添加到 http://site:/ ,则不起作用。 /site:80/personal/最后一个/

有谁知道为什么?事件处理程序功能的范围是site,我的理解是它应该适用于所有子站点。

I have a SharePoint 2010 MySites set up on its own web application. There is the standard site collection at the base level, http://site:80/.

The personal sites for each user is at the managed URL /personal/.

I have a working event handler which add items to the Newsfeed when a user adds something to a picture library.

THE PROBLEM:
The problem is, this only works if they add to a picture library at the base site collection, http://site:80/, and does NOT work if they add to http://site:80/personal/last first/.

Does anyone know why? The event handler feature is site scoped and my understanding is that it should work on all subsites.

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

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

发布评论

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

评论(2

弥繁 2024-12-17 06:04:45

问题是个人网站不是“我的网站”主机的子网站。事实上,每个用户的个人网站都是一个独立的网站集。因此,基本上,您不仅需要为“我的网站”主机注册事件接收器,还需要为每个用户的个人网站注册事件接收器。

The problem is that personal sites are not subsites of My Site host. In fact each user's personal site is a site collection on its own. So basically you need to register your event receiver not only for My SIte host, but also for each user's personal site.

暖树树初阳… 2024-12-17 06:04:45

好的。由于您只能将功能“装订”到将来配置的站点定义,因此您需要一种方法来激活现有站点上的新功能。

因此,我发现并使用的修复如下:

新闻源的默认页面是http://site:80/default.aspx。如果您创建事件接收器并将其范围限定为“站点”并将其全局部署或部署到该 Web 应用程序,则它将在基本网站集上运行。每个个人网站都是一个网站集,并且具有该功能,但需要在每个个人网站集上激活它。

因此,在 default.aspx 页面中,您可以放置​​以下内容,这将激活该功能(如果尚未激活)。

<script runat="server" type="text/c#">
protected override void OnLoad(EventArgs e) {
  base.OnLoad(e);

  String sAccount = (((SPWeb)((SPSite)SPContext.Current.Site).OpenWeb()).CurrentUser.LoginName).Split('\\')[1];
  String basePersonalURL = "http://site:80/personal/";
  String eventReceiverFeatureId = "12345678-1234-1234-1234-1234567890ab";

  using(SPSite site = new SPSite(basePersonalURL + sAccount)) {
    site.AllowUnsafeUpdates = true;
    using(SPWeb web = site.RootWeb) {
      web.AllowUnsafeUpdates = true;

      try { site.Features.Add(new Guid(eventReceiverFeatureId)); } catch {}

      web.AllowUnsafeUpdates = false;
    }
    site.AllowUnsafeUpdates = false;
  }
}
</script>

您还需要编辑 web.config 文件以允许内联代码为此页面运行。希望这有帮助。

Ok. Because you can only 'staple' features to site definitions which will be provisioned in the future, you need a way to activate new features on existing sites.

So, the fix I discovered and used follows:

The default page for the newsfeed is http://site:80/default.aspx. If you create an event receiver and scope it for 'site' and deploy it globally or to that web application, then it will work on the base site collection. Each personal site is a site collection and has the feature but it needs to be activated on each personal site collection.

So, in the default.aspx page, you place the following which will activate the feature if it has not yet been activated.

<script runat="server" type="text/c#">
protected override void OnLoad(EventArgs e) {
  base.OnLoad(e);

  String sAccount = (((SPWeb)((SPSite)SPContext.Current.Site).OpenWeb()).CurrentUser.LoginName).Split('\\')[1];
  String basePersonalURL = "http://site:80/personal/";
  String eventReceiverFeatureId = "12345678-1234-1234-1234-1234567890ab";

  using(SPSite site = new SPSite(basePersonalURL + sAccount)) {
    site.AllowUnsafeUpdates = true;
    using(SPWeb web = site.RootWeb) {
      web.AllowUnsafeUpdates = true;

      try { site.Features.Add(new Guid(eventReceiverFeatureId)); } catch {}

      web.AllowUnsafeUpdates = false;
    }
    site.AllowUnsafeUpdates = false;
  }
}
</script>

You also need to edit the web.config file in order to allow inline code to run for this page. Hope this helps.

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