A simple, full‑stack .NET solution for managing employees. It includes an ASP.NET Core Web API, a Blazor front end, shared model classes, and a small shared UI components library.
BlazorTutorials.sln
├─ EmployeeManagment.Api/ # ASP.NET Core Web API (Employees, etc.)
├─ EmployeeManagment.Web/ # Blazor app (UI)
├─ EmployeeManagment.Models/ # Shared POCOs / contracts
└─ GlobalResource.Components/ # Reusable UI components (confirm dialogs, etc.)
- ASP.NET Core Web API for CRUD operations
- Blazor UI with reusable components (e.g., confirmation dialog)
- Shared models between API and UI
- Ready for local development with the
dotnetCLI
- .NET SDK (LTS recommended, e.g., .NET 8)
- A code editor (VS Code or Visual Studio 2022+)
- Optional: SQL Server/SQLite if you wire up persistent storage
Clone the repo and restore packages:
git clone <your-repo-url>
cd <repo-root>
dotnet restoredotnet run -p EmployeeManagment.Api/EmployeeManagment.Api.csprojThis starts the API locally (watch the console for the exact URL/port).
Make sure the Blazor app points to the API base URL (configured where you register HttpClient or in appsettings.*.json). Then run:
dotnet run -p EmployeeManagment.Web/EmployeeManagment.Web.csprojOpen the printed URL (e.g., https://localhost:xxxx) in your browser.
- API base address (Web): Set the API URL used by
HttpClientin the Blazor app (Program/DI orappsettings.*.json). - CORS (API): If you change ports or deploy separately, ensure the API has a CORS policy that allows the Blazor origin.
- Database: If you move beyond in‑memory data, add EF Core (or your preferred ORM) and connection strings in the API’s
appsettings.*.json.
Paths may vary depending on your controllers. Adjust as needed.
GET /api/employees— list employeesGET /api/employees/{id}— detailsPOST /api/employees— createPUT /api/employees/{id}— updateDELETE /api/employees/{id}— delete
- Hot reload:
dotnet watchworks well during UI/API changes. - Models: Keep DTOs in
EmployeeManagment.Modelsso API and Web stay in sync. - Components: Put cross‑cutting UI (like confirmation modals) in
GlobalResource.Componentsand reference them from the Blazor app.
- 404s from Web → API: Confirm the API URL and port match what the Blazor
HttpClientis using. - CORS errors: Add/adjust a permissive CORS policy in the API for your local Blazor origin during development.
- Project name/path mismatches: If the solution references a folder that doesn’t exist locally, fix the path in the
.slnor rename the folder.
# Build everything
dotnet build
# Run API
dotnet run -p EmployeeManagment.Api/EmployeeManagment.Api.csproj
# Run Web
dotnet run -p EmployeeManagment.Web/EmployeeManagment.Web.csproj
# Hot reload (example)
dotnet watch --project EmployeeManagment.Web/EmployeeManagment.Web.csproj run
``
## Roadmap
- Add EF Core + migrations for persistence
- Add Swagger/OpenAPI to the API
- Add unit tests for controllers/services
- CI pipeline (build + test)
## License
MIT — feel free to use and modify.