Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Web.Http.Authorize中的数组使用情况_C# - Fatal编程技术网

C# System.Web.Http.Authorize中的数组使用情况

C# System.Web.Http.Authorize中的数组使用情况,c#,C#,我想知道的不是固定的字符串 [System.Web.Http.Authorize(Roles ="Admin,UlooDaPahta,ChawalManager," )] 我们可以在角色中使用字符串/数组吗 [System.Web.Http.Authorize(Roles =MyStr)] [System.Web.Http.Authorize(Roles =MyArray)] 谢谢当然,只要它是一个常量。属性参数在编译时计算,所以答案是否定的。但是角色是动态的,新角色应该添加到数据库中。您

我想知道的不是固定的字符串

[System.Web.Http.Authorize(Roles ="Admin,UlooDaPahta,ChawalManager," )]
我们可以在角色中使用字符串/数组吗

[System.Web.Http.Authorize(Roles =MyStr)]

[System.Web.Http.Authorize(Roles =MyArray)]

谢谢

当然,只要它是一个
常量
。属性参数在编译时计算,所以答案是否定的。但是角色是动态的,新角色应该添加到数据库中。您可以构建自己的授权过滤器,将数组作为参数。看看这里->