Full Application - Blazor WebAPI Project Template
Published: January 11, 2026
Building a new web application from scratch involves a lot of repetitive setup: configuring authentication, structuring the project layers, setting up the database, implementing CRUD operations, adding authorization, and integrating email functionality. The stock templates from Microsoft give you a starting point, but they don’t include everything you need for a real application. I created the Blazor WebAPI Template to solve this problem - it’s a production-ready template that includes all the foundational pieces I need when starting a new project.
This template demonstrates a complete application architecture using .NET 10, Blazor WASM for the frontend, Web API for the backend, SQLite for the database, and ASP.NET Identity for authentication and authorization. It’s actively maintained and updated as .NET evolves. If you’re building line-of-business applications, internal tools, or any web application that needs user management and data operations, this template gives you a solid foundation to build on.
What’s Inside
The template includes everything you need to hit the ground running:
Technologies:
- .NET 10 & C#
- Blazor WASM for the client application
- Web API for backend services
- SQLite database (easily switchable to SQL Server or Azure SQL)
- ASP.NET Identity API with 2FA support
- Blazored libraries (Toast notifications, LocalStorage, Modal dialogs)
- Bootstrap 5 via CDN for UI components and icons
- GitHub Actions for CI/CD
Key Features:
- Complete authentication and authorization system using ASP.NET Identity
- User registration with optional email confirmation
- Password recovery and account management
- Two-factor authentication support
- CRUD operations with search functionality
- Admin panel for managing users and system settings
- Built-in email integration via SMTP2GO
- Automatic database migrations
- Clean separation of concerns with a multi-project architecture
- API documentation with Scalar
Architecture That Makes Sense
One of my favorite aspects of this template is the clean architecture. The solution is organized into five projects, each with a clear responsibility:
API Project: Handles HTTP requests, manages authentication/authorization, and hosts both the API and the Blazor app in the same process. This eliminates complex CORS configurations while keeping the application easy to deploy. The API delegates all business logic to the Service layer rather than handling it directly.
Service Project: The middle layer where all business logic and database operations live. The API doesn’t touch the database directly - it goes through the Service layer. This separation makes the codebase more maintainable and testable.
App Project: The Blazor WASM frontend that consumes the API. It’s hosted within the API process, so you get a single deployable unit.
Dto Project: Contains data transfer objects shared across the API, Service, and App projects. This keeps your contracts consistent and avoids duplication.
Database Project: Houses all entities and the DbContext. This separation makes it easier to manage migrations and keeps your data layer isolated.
This architecture makes it easy to understand where code belongs and prevents the common mistake of mixing concerns. When you need to add a new feature, you know exactly where each piece goes.
Getting Started in Minutes
Getting the template up and running is straightforward. Here’s the process:
1. Create your project from the template:
Use GitHub’s “Use this template” feature to create a new repository from the template. This gives you a clean copy to work with. Then clone your new repository.
2. Rename the project:
The template includes a PowerShell script that renames everything from “BlazorTemplate” to your project name. Make sure to close all editors (VS Code, Visual Studio) before running this to ensure all files can be updated:
.\RenameProject.ps1 -FolderPath . -OldName "BlazorTemplate" -NewName "YourProjectName"
This script updates folder names, file names, and code references throughout the entire solution. Once you’re done, you can delete the script - you won’t need it again unless you want to rename your project in the future.
3. Start the application:
From the root of your solution, run:
dotnet watch --project YourProjectName.API
The API project acts as the host for both the API and the app. On first startup, the database will be created automatically - no manual migration steps required.
4. Start using the application:
Open your browser and navigate to the URL shown in the console (typically https://localhost:5001). You can create data through the UI, or use the API’s seed endpoint to generate sample data for experimentation.
The first user to register automatically becomes an administrator with access to admin features. There are no external dependencies required to get started - everything works out of the box with SQLite.
Authentication Done Right
Authentication is handled entirely by ASP.NET Identity, and it’s stored in your own database. This gives you complete control over your user data and the authentication process. No external identity providers required, though you can add them if needed.
The template includes all the standard authentication features:
- User registration with optional email confirmation
- Secure login with cookie-based authentication
- Password recovery via email
- Two-factor authentication (2FA)
- Account management (change password, email, etc.)
- Role-based authorization (Admin role built-in)
Why Identity? It’s quick to set up, easy to customize, supported by Microsoft, and gives you 100% control. While there are other options like Azure B2C, Entra, or Auth0, Identity is perfect for applications where you want to own the entire authentication stack.
Email Integration with SMTP2GO
The template integrates with SMTP2GO for sending emails. While the application works without it, some features require email functionality:
- Account activation and email confirmation
- Password recovery
- Allowing users to change their email/username
Setting up SMTP2GO is straightforward - create a free account, get your API key, and configure it in the admin settings. The admin panel includes fields for setting your SMTP2GO API key and the system email address. It’s a simple, reliable solution that doesn’t require running your own mail server.
Admin Features
The template includes built-in admin functionality that makes managing your application easier:
- Enable or disable user registration
- View and manage registered users
- Delete user accounts
- Configure SMTP2GO settings directly in the UI
- Set system-wide configuration values
The first user to register is automatically granted the admin role, so you’re ready to manage the application immediately after deployment.
Database Flexibility
The template uses SQLite by default because it’s simple, requires no external database server, and works on both Windows and Linux. The database is created automatically on first run, and migrations are applied automatically.
For production applications that need more than SQLite offers, switching to SQL Server or Azure SQL is straightforward. The template uses Entity Framework Core, so changing databases is just a matter of updating the connection string and generating new migrations. If you switch databases, delete the existing SQLite migrations and create a fresh “Initial Migration” for your new database.
Database migrations are handled automatically in Program.cs, but you can run them manually if needed:
dotnet ef migrations add InitialCreate --project YourProjectName.Database --startup-project YourProjectName.API
dotnet ef database update --project YourProjectName.Database --startup-project YourProjectName.API
API-Only Option
If you don’t need the Blazor frontend and just want a Web API, the template accommodates that too. Simply:
- Delete the App project and remove references from the solution
- Remove
app.MapStaticAssets();from Program.cs - Remove
app.MapFallbackToFile("index.html");from Program.cs
After these changes, you have a clean API-only application. Navigate to /scalar (or your configured route) to access the API documentation.
API Versioning
The template handles API versioning manually by including version numbers in the route paths (e.g., /api/v1/items). This is simple and explicit. If you prefer automated versioning tools, you can easily integrate packages like Asp.Versioning.Mvc, but the manual approach works well for most applications and keeps dependencies minimal.
Development Workflow
The template includes everything you need for a smooth development workflow:
- API Documentation: Built-in Scalar documentation at
/scalarshows all endpoints with request/response examples - .http files: Included in the API project for testing endpoints directly in VS Code
- Hot reload: Use
dotnet watchfor automatic reloading during development - Sample data: Seed endpoints let you generate test data quickly
Deployment Considerations
I host this template on Ubuntu servers because SQLite doesn’t perform reliably on Azure App Services in my experience. The repository includes a GitHub Actions workflow that demonstrates deploying to a Linux server. If you’re deploying to Azure App Service, I recommend switching to Azure SQL instead of SQLite.
The template includes a GitHub Actions workflow you can reference for CI/CD setup. Feel free to reach out if you need help setting up a deployment pipeline.
Security Best Practices
The template follows security best practices out of the box:
- Passwords are hashed using ASP.NET Identity’s secure defaults
- Authentication tokens use secure cookie-based auth
- HTTPS is enforced in production
- Sensitive configuration is kept in appsettings.json (not checked into source control)
For sensitive configuration data like connection strings, use these commands to prevent accidentally committing them:
git update-index --assume-unchanged .\YourProjectName.API\appsettings.json
To reverse:
git update-index --no-assume-unchanged .\YourProjectName.API\appsettings.json
Why I Built This
The stock Microsoft templates are great for learning, but they don’t include the features you need for real applications. Every time I started a new project, I found myself implementing the same patterns: setting up a clean architecture, adding Identity, configuring email, creating admin features, and building CRUD operations. This template is the result of building those features many times and distilling them into a reusable starting point.
I keep this template actively maintained and updated with each .NET release. It reflects the architecture and patterns I use in production applications, and I continue to refine it based on real-world experience.
Get Started
Ready to try it? Head over to the GitHub repository, use the template feature to create your own copy, and follow the getting started steps above. In just a few minutes, you’ll have a complete application foundation ready for your next project.
The template uses the Unlicense license, so you’re free to use it however you want - commercial projects, personal projects, modify it, redistribute it, whatever you need.
Build something amazing!