Skip to content

Instantly share code, notes, and snippets.

@nmchenry01
Last active November 28, 2021 15:43
Show Gist options
  • Save nmchenry01/936f96b77bd886ee255d1b5d0a0ab749 to your computer and use it in GitHub Desktop.
Save nmchenry01/936f96b77bd886ee255d1b5d0a0ab749 to your computer and use it in GitHub Desktop.
An example of using the AuthorizeAttribute with admin authorization on a .NET Controller
[ApiController]
public class AdminProductController : ControllerBase
{
[HttpPost("product/{Id}")]
[Authorize("admin")]
public ActionResult Post(AddProductRequestDto addProductRequest)
{
// Add some product
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment