【发布时间】:2020-05-14 19:05:53
【问题描述】:
我有控制器,其中某些方法具有授权属性,某些方法具有 AllowAnonymous 所以,我想在调用方法时检查是 Authorize 还是 AllowAnonymous
这是我的控制器,方法名为 login
[AllowAnonymouse]
Public ActionResult Login(){}
所以在不同的类中我想检查这个方法是 Authorize 还是 AllowAnonymous
【问题讨论】:
-
使用反射,
typeof(YourController).GetMethod("Login").GetCustomAttributes()
标签: c# asp.net-mvc