Skip to content

Srikanth9793/BlazorWebApp

Repository files navigation

Employee Management (Blazor + ASP.NET Core)

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.

Solution layout

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.)

Features

  • 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 dotnet CLI

Prerequisites

  • .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

Quick start

Clone the repo and restore packages:

git clone <your-repo-url>
cd <repo-root>
dotnet restore

1) Run the API

dotnet run -p EmployeeManagment.Api/EmployeeManagment.Api.csproj

This starts the API locally (watch the console for the exact URL/port).

2) Run the Blazor app

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.csproj

Open the printed URL (e.g., https://localhost:xxxx) in your browser.

Configuration

  • API base address (Web): Set the API URL used by HttpClient in the Blazor app (Program/DI or appsettings.*.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.

Typical endpoints

Paths may vary depending on your controllers. Adjust as needed.

  • GET /api/employees — list employees
  • GET /api/employees/{id} — details
  • POST /api/employees — create
  • PUT /api/employees/{id} — update
  • DELETE /api/employees/{id} — delete

Development tips

  • Hot reload: dotnet watch works well during UI/API changes.
  • Models: Keep DTOs in EmployeeManagment.Models so API and Web stay in sync.
  • Components: Put cross‑cutting UI (like confirmation modals) in GlobalResource.Components and reference them from the Blazor app.

Common issues & fixes

  • 404s from Web → API: Confirm the API URL and port match what the Blazor HttpClient is 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 .sln or rename the folder.

Handy commands

# 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.

About

Blazor web application client -> blazor server -> asp.net core web api -> databses

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors