У меня есть контроллер в ASP.NET MVC, который я ограничил роль администратора:
[Authorize(Roles = "Admin")]
public class TestController : Controller
{
...
Если пользователь, который не входит в роль администратора, переходит к этому контроллеру, их приветствует пустой экран.
То, что я хотел бы сделать, это перенаправить их на View, в котором говорится: "вам нужно быть в роли администратора, чтобы иметь доступ к этому ресурсу".
Один из способов сделать это, о котором я думал, - это проверить каждый метод действия на IsUserInRole(), а если нет в роли, верните это информационное представление. Тем не менее, я должен был бы добавить это в каждое действие, которое нарушает принцип DRY и, очевидно, громоздко поддерживать.