MSDN Documentation

Welcome to Blazor: Build Interactive Web UIs with C#

Blazor is a .NET web framework for building interactive client-side web UIs with C# instead of JavaScript. Blazor allows you to build modern web applications by leveraging your existing .NET skills and tools.

What is Blazor?

Blazor is an open-source, cross-platform framework that enables developers to create interactive web applications using C# and .NET. It offers two hosting models:

Blazor components are reusable pieces of UI logic. They are built using Razor syntax, which mixes HTML markup with C# code.

Key Benefits of Blazor

Getting Started with Blazor

To start developing with Blazor, you'll need the latest .NET SDK installed. You can create a new Blazor project using the .NET CLI:


dotnet new blazorwasm -o MyBlazorApp
cd MyBlazorApp
dotnet run
            

This command creates a new Blazor WebAssembly project named `MyBlazorApp` and runs it.

Blazor Component Model

Blazor applications are composed of components. A component is a piece of UI, such as a page, a form, a menu, or any reusable UI element. Components are typically defined in files with a .razor extension.

Here's a simple example of a Blazor component:


@Message

@code { private string Message { get; set; } = "Hello from Blazor!"; private void UpdateMessage() { Message = "Button clicked!"; } }

In this example:

Next Steps

Now that you have a basic understanding of Blazor, you can explore more advanced topics:

For comprehensive API reference and detailed guides, please visit the official Blazor API documentation.