Authorize Resource Tag Helper for ASP.NET Core

ASP.NET Core has a powerful mechanism for implementing resource-based authorization using the IAuthorizationService and resource-based AuthorizationHandlers. In this blog post, we build a tag helper that makes it simple to use resource-based auhtorization to Razor views without writing any C# code in the view.

Authorize Tag Helper for ASP.NET Core

In ASP.NET Core, it's easy to control access to Controllers and Action Methods using the Authorize attribute. This attribute provides a simple way to ensure only authorized users are able to access certain parts of your application. While the Authorize attribute makes it easy to control authorization for an entire page, the mechanism for controlling access to a section of a page is a little clumsy. In this blog post, we build a Tag Helper that makes it incredibly easy to control access to any block HTML in a Razor view.