Can you enable [Authorize] for controller but disable it for a single action?

前端 未结 4 1080
长发绾君心
长发绾君心 2021-01-31 20:04

I would like to use [Authorize] for every action in my admin controller except the Login action.

[Authorize (Roles = \"Administrator\"         


        
4条回答
  •  星月不相逢
    2021-01-31 21:08

    You can decorate your controller with [Authorize] and then you can just decorate the method that you want to exempt with [AllowAnonymous]

提交回复
热议问题