This repository demonstrates how to use built-in authentication and authorization features in .NET Blazor applications.
Specifically, this project highlights:
- Securing pages and components using the
[Authorize]
attribute. - Conditionally rendering content with the
AuthorizeView
component based on user authentication status. - Integration with the built-in ASP.NET Core Identity and authentication system.
- Examples of secured Razor components.
- Conditional UI rendering based on user authentication.
- Easy-to-follow authentication logic implementation.
Watch the detailed video walkthrough:
git clone https://github.com/CoderFoundry/AuthDemoYT.git
- Open the solution in Visual Studio or your preferred IDE.
- Build and run the project.
- The application will automatically:
- Create a SQLite database named
AuthDemoApp.db
. - Run migrations to configure ASP.NET Identity.
- Set up two default users for immediate testing.
- Create a SQLite database named
Modify the settings in appsettings.json
if needed:
"ConnectionStrings": {
"DbConnection": "Data Source=AuthDemoApp.db"
},
"DefaultPassword": "Password123@"
DbConnection
: Set a custom database file or connection string.DefaultPassword
: Change the default password for the created users.
Important: The
DbConnection
setting is required unless you're modifying the database connection handling logic in the code.
- .NET SDK
- Visual Studio or Visual Studio Code
Contributions via pull requests or issue submissions are welcome!
This project is licensed under the MIT License. See LICENSE for more details.