What is C# Blazor?
Blazor is a new .NET web framework for creating client-side applications using C#/Razor and HTML that runs in the browser with WebAssembly. Blazor lets you build interactive web UIs using C# instead of JavaScript. Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Both client and server code is written in C#, allowing you to share code and libraries.
WebAssembly & C#?
JavaScript is a powerful language but it has its disadvantages. Some are fixed by TypeScript. However, using C# for client-side web development is compelling for many people because of reasons like the following:
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
int currentCount = 0;
void IncrementCount()
{
currentCount++;
}
}
The .NET code runs inside the context of WebAssembly. You're running "a .NET" inside your browser on the client-side with no plugins, no Silverlight, Java, Flash, just open web standards.
live demo: https://blazor-demo.github.io/Counter
Getting started with Blazor?
In order to get started with Blazor you need to install a few prerequisites:
https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=visual-studio
Blazor is a new .NET web framework for creating client-side applications using C#/Razor and HTML that runs in the browser with WebAssembly. Blazor lets you build interactive web UIs using C# instead of JavaScript. Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Both client and server code is written in C#, allowing you to share code and libraries.
WebAssembly & C#?
JavaScript is a powerful language but it has its disadvantages. Some are fixed by TypeScript. However, using C# for client-side web development is compelling for many people because of reasons like the following:
- C# is a very robust and feature-rich language that has proven to be successful for projects and teams of all sizes
- Existing C# code could be re-used
- ASP.NET Core is a powerful programming framework for server-side web development. Enabling C# on the client would allow teams to use a common technology - stack on server and client.
- Compact and fast to parse/load so it can be efficiently transferred over the wire, loaded and executed by the browser
- Compatible with the existing web platform. Can run alongside JavaScript, allows calls to/from it, can get access to the Browser APIs and runs in the same secure sandbox as JavaScript code
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
int currentCount = 0;
void IncrementCount()
{
currentCount++;
}
}
The .NET code runs inside the context of WebAssembly. You're running "a .NET" inside your browser on the client-side with no plugins, no Silverlight, Java, Flash, just open web standards.
live demo: https://blazor-demo.github.io/Counter
Getting started with Blazor?
In order to get started with Blazor you need to install a few prerequisites:
- Install Visual Studio 2017, version 15.7 or later.
- Install the .NET Core 2.1 SDK, version 2.1.300 or later
- Install the Blazor Language Services extension for VS
- Optionally install the templates for the dotnet new command by running dotnet new -i Microsoft.AspNetCore.Blazor.Templates::* in the console.
https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=visual-studio
Comments
Post a Comment