Use [Authorize] on your API controllers:?
Short answer: [Authorize] [ApiController] [Route("api/[controller]")] public class OrdersController : ControllerBase { [HttpGet] public IActionResult GetOrders() => Ok("Secured Orders"); } [Authorize] [ApiController] [Route("api/[controller]")] public class OrdersController : ControllerBase { [HttpGet] public IActionResult GetOrders() =>… Ok("Secured Orders"); }… [Authorize] [ApiController] [Route("api/[controller]")] public…
Explain a bit more
class OrdersController : ControllerBase { [HttpGet] public IActionResult GetOrders() => Ok("Secured Orders"); } [Authorize] [ApiController] [Route("api/[controller]")] public class OrdersController : ControllerBase { [HttpGet] public IActionResult GetOrders() =>… Ok("Secured Orders"); }
Real-world example (ShopNest)
ShopNest admin screens use MVC: controller loads data, Razor view renders HTML, Tag Helpers build forms safely.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png