ASP.NET MVC Custom Authorization

前端 未结 3 701
孤城傲影
孤城傲影 2020-12-22 18:51

I have a question about custom authorization in MVC.

I have a site that I want to limit access to certain pages, depending on their group membership. Now I have see

3条回答
  •  生来不讨喜
    2020-12-22 19:24

    If the authorization is really that dynamic, I would handle it in the controller. I have one action where I do this - you can return a HttpUnauthorizedResult to redirect to the login page or you can show a custom error in your view.

    I don't the default redirect to the login page when somebody is already logged in, but not in the correct role. That's very confusing for the user.

提交回复
热议问题