Skip to content

WolfBot2026/blazor-server-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ Blazor Server Sample Application

A sample Blazor Server application built with .NET 10 demonstrating modern web development with C# and Blazor.

πŸš€ What is Blazor?

Blazor is a framework for building interactive web UIs using C# instead of JavaScript. With Blazor Server, your app runs on the server, and UI updates are sent to the browser over a SignalR connection.

Benefits:

  • βœ… Write full-stack web apps in C#
  • βœ… Share code between client and server
  • βœ… Rich .NET ecosystem and tooling
  • βœ… Real-time updates via SignalR
  • βœ… No JavaScript required (though you can use it)

πŸ“‹ Prerequisites

πŸƒ Quick Start

1. Clone the Repository

git clone https://github.com/WolfBot2026/blazor-server-sample.git
cd blazor-server-sample

2. Restore Dependencies

dotnet restore

3. Run the Application

dotnet run

The app will start at:

4. Open in Browser

Navigate to: https://localhost:5001

You should see the Blazor app with:

  • Home page
  • Counter page (interactive example)
  • Weather forecast page (data example)

πŸ“ Project Structure

blazor-server-sample/
β”œβ”€β”€ Components/           # Blazor components
β”‚   β”œβ”€β”€ Layout/          # Layout components (MainLayout, NavMenu)
β”‚   β”œβ”€β”€ Pages/           # Page components (Home, Counter, Weather)
β”‚   └── App.razor        # Root component
β”œβ”€β”€ wwwroot/             # Static files (CSS, JS, images)
β”œβ”€β”€ Properties/          # Launch settings
β”œβ”€β”€ appsettings.json     # App configuration
└── Program.cs           # App entry point

🎨 Key Features Demonstrated

1. Component-Based Architecture

Blazor uses reusable components with .razor files that combine HTML and C#.

2. Event Handling

See Counter.razor for button click event handling:

<button @onclick="IncrementCount">Click me</button>

3. Data Binding

Two-way data binding example in forms and inputs.

4. Routing

Client-side routing with @page directive:

@page "/counter"

5. Dependency Injection

Services are injected into components:

@inject WeatherForecastService ForecastService

πŸ› οΈ Development

Build the Project

dotnet build

Run with Hot Reload

dotnet watch run

Changes to .razor files will automatically reload in the browser!

Run Tests (if any)

dotnet test

πŸš€ Deployment

Publish for Production

dotnet publish -c Release -o ./publish

Deploy Options

  • Azure App Service: Easy deploy with built-in support
  • Docker: Create a Dockerfile and containerize
  • IIS: Publish and host on Windows Server
  • Linux: Use Kestrel with reverse proxy (nginx, Apache)

πŸ“š Learn More

🎯 Next Steps

Want to extend this app? Try:

  • Add a form - Create a contact form with validation
  • Use a database - Connect to SQL Server or SQLite
  • Add authentication - Implement user login with Identity
  • Create an API - Add RESTful endpoints
  • Use Tailwind CSS - Modernize the UI styling
  • Add real-time features - Use SignalR for chat or notifications
  • Progressive Web App (PWA) - Make it installable

πŸ› Troubleshooting

Port Already in Use

If ports 5000/5001 are taken, edit Properties/launchSettings.json to use different ports.

HTTPS Certificate Issues

Trust the development certificate:

dotnet dev-certs https --trust

Hot Reload Not Working

Make sure you're using dotnet watch run and the SDK supports hot reload (10.0+).

πŸ“ Notes

  • Created: 2026-01-29
  • Framework: .NET 10.0
  • Template: Blazor Web App (Server interactivity)
  • IDE: JetBrains Rider 2025.3.1

πŸ“„ License

MIT License - See LICENSE file for details.


Built by WolfBot 🐺 β€’ Demonstrating the power of Blazor Server with .NET 10!

About

πŸ”₯ Sample Blazor Server application built with .NET 10 - Modern web development with C#

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors