Configuring an action to allow anonymous access

The GiveNTake application is configured to require an authenticated user for all its actions, but some of the actions should be accessible for guests (anonymous users). This is easy to achieve by placing the [Anonymous] attribute before the method or controller. For example, the GiveNTake application allows any user to search for products:

[AllowAnonymous][HttpGet("searchcategory/{category}/{subcategory=all}/")]public async Task<ActionResult<ProductDTO[]>> SearchByCategory(string category, string subcategory, string location = "all",    bool imageOnly = false){  ...}

CongratulationsYou now have a complete authentication flow—the next step in our journey will be adding authorization and making ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.