The blog post https://johanbostrom.se/blog/adding-basic-auth-to-your-mvc-application-in-dotnet-core/ mentioned “There are a few ways to solve this problem, down below you can find three of them.” I found only 2 : Attribute(applied to controller) and Middleware. also I suggest To create repository readme and provide link to the blog post.