Resolving authentication state in procedural logic
Incorporating authentication and authorization into the procedural logic of your application is often necessary. Simply manipulating markup visibility may not suffice in these scenarios; you need to resolve the current authentication state to make informed decisions within your code. That’s where a cascading AuthenticationState
class comes in. The AuthenticationState
class is a built-in Blazor feature that provides information about the user’s authentication status and claims.
Let’s add a button that redirects internal employees to different areas of a ticketing system based on their roles.
Getting ready
Before we leverage authentication state in procedural logic, do the following:
- In the server-side project, create a
Components
/Recipes
/Recipe07
directory – this will be your working directory - Copy the
FakePages
directory from theComponents
/Recipes
/Recipe07
directory in the GitHub repository...