gpt4 book ai didi

c# - 自定义 AuthorizeAttribute 角色属性为空

转载 作者:太空狗 更新时间:2023-10-29 23:53:42 24 4
gpt4 key购买 nike

我已经从 AuthorizeAttribute 实现了 RoleAuthorize 类

public sealed class RoleAuthorize : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var roles = Roles;

return false;
}
}

但是当过滤器发生时属性 Roles 为空。谢谢。

最佳答案

您是否像这样在操作方法中应用过滤器?

[RoleAuthorize(Roles = "MyRole")]
public ActionResult MyAction()
{
return View();
}

关于c# - 自定义 AuthorizeAttribute 角色属性为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17639849/

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