【问题标题】:Get roles of page with role based protection使用基于角色的保护获取页面角色
【发布时间】:2019-08-11 18:59:56
【问题描述】:

umbraco.cms.businesslogic.web.Access.GetAccessingMembershipRoles 的当前替代方案是什么?因为 umbraco 7.6 将其突出显示为已过时并告诉使用IPublicAccessService

我不知道如何使用它,我只能

IContent content = GetById(id);
Attempt<PublicAccessEntry> access = _publicAccessService.IsProtected(content);

其中没有关于当前页面角色的任何信息。

【问题讨论】:

  • 请在下面查看我对您问题的回答@nickornotto,并在自己测试后将其标记为正确答案。

标签: umbraco umbraco7 user-roles


【解决方案1】:

这就是你的做法;

IContent content = GetById(id);
var publicAccessService = ApplicationContext.Current.Services.PublicAccessService;
var entryForContent = publicAccessService.GetEntryForContent(content);

你会看到 entryForContent 结果有规则,这就是你需要的。请参阅下面的详细信息;

【讨论】:

  • 太好了,这就是我所缺少的。谢谢!
猜你喜欢
  • 2015-04-07
  • 2021-11-12
  • 2023-03-30
  • 2018-06-18
  • 1970-01-01
  • 2017-04-27
  • 1970-01-01
  • 2020-11-22
  • 1970-01-01
相关资源
最近更新 更多