【发布时间】:2014-05-14 20:20:18
【问题描述】:
我想说清楚,我已经尝试了几乎可以想象的东西。
我的 las 拍摄是这样的。
[Authorize()]
[Secure(Roles = ActionRole.Admin.ToString())]
public class ActionController : Controller
{
public enum ActionRole
{
Admin,
Recruter,
Sales,
Developer
}
}
还有我最初的想法。
[Authorize()]
[Secure(Roles = MyRoleClass.GetAuthorizedRolesForThisAction("ActionController"))]
public class ActionController : Controller
{
//ActionController Related Code.
}
public Class MyRoleClass(){
Public strgin GetAuthorizedRolesForThisAction(string Controller){
//Accessing my DB and the searching is not the hard part here.
}
}
我收到此错误。
Error 1 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
我正在尝试这样做,因为不是我的想法,每次我都必须更改控制器角色权限......如果有人有想法,将不胜感激。
【问题讨论】:
-
安全是自定义属性吗?它看起来像什么?
标签: c# asp.net security asp.net-mvc-4