Blazor

Blazor is a free and open-source web framework that enables developers to create web applications using C# and HTML.[1][2][3][4][5][6] It is being developed by Microsoft.

Blazor
Original author(s)Microsoft
Developer(s).NET Foundation
Initial release2018 (2018)
Repositorygithub.com/dotnet/aspnetcore/tree/master/src/Components
Operating systemLinux, macOS, Windows
Included withASP.NET Core
TypeWeb framework
LicenseApache License 2.0
Websiteblazor.net

A Blazor app can interop with JavaScript (with both running on the client side), e.g. call (reuse) JavaScript functions from .NET methods.[7]

Overview

Five different editions of Blazor apps have been announced.

  • Blazor Server: These apps are hosted on an ASP.NET Core server in ASP.NET Razor format. Remote clients act as thin clients, meaning that the bulk of the processing load is on the server. The client's web browser downloads a small page and updates its UI over a SignalR connection. Blazor Server was released as a part of .NET Core 3.[8]
  • Blazor WebAssembly: Single-page apps that are downloaded to the client's web browser before running. The size of the download is larger than for Blazor Server, depends on the app, and the processing is entirely done on the client hardware. However, this app type enjoys rapid response time. As its name suggests, this client-side framework is written in WebAssembly, as opposed to JavaScript (while they can be used together). Blazor WebAssembly 3.2.0 was released on May 19th, 2020.[9]

Microsoft plans to release Blazor PWA and Blazor Hybrid editions. The former supports progressive web apps (PWA). The latter is a platform-native framework (as opposed to a web framework) but still renders the user interface using web technologies (e.g. HTML and CSS). A third, Blazor Native – platform-native framework that renders a platform-native user interface – has also been considered but has not reached the planning stage.[8]

Support

Since version 5.0 Blazor is dropping support for some old web browsers. While current Microsoft Edge works, the legacy version of it, i.e. "Microsoft Edge Legacy" and Internet Explorer 11 are dropped when you use Blazor.[10]

Example

The following example shows how to implement a simple counter that can be incremented by clicking a button:

<h1>Blazor code example</h1>
<p>count: @count</p>
<button class="btn btn-primary" @onclick="IncCount">Click to increment</button>

@code {
  private int count = 0;

  private void IncCount()
  {
    count++;
  }
}

See also

  • asm.js – precursor technology of WebAssembly allowing applications written in C or C++ to run in client-side web applications.
  • Google Native Client – now deprecated Google's precursor technology of WebAssembly that allows running native code from a web browser, independent of browser's operating system

References

  1. Strahl, Rick (July 31, 2018). "Web Assembly and Blazor: Re-assembling the Web". Archived from the original on 2018-10-22. Retrieved 2018-10-22.
  2. Tomassetti, Federico (September 4, 2018). "Blazor: .NET in the Browser". Archived from the original on 2018-10-22. Retrieved 2018-10-22.
  3. Stropek, Rainer (September 2018). "Learn Blazor". Archived from the original on 2018-10-22. Retrieved 2018-10-22.
  4. James, Mike (February 12, 2018). "Blazor .NET In The Browser". Retrieved 2018-10-23.
  5. "Web Development - C# in the Browser with Blazor". MSDN Magazine. September 2018. Archived from the original on 2018-10-22. Retrieved 2018-10-22.
  6. "Get started building .NET web apps that run in the browser with Blazor". ASP.NET Blog. March 22, 2018. Retrieved 2018-10-22.
  7. guardrex. "Call JavaScript functions from .NET methods in ASP.NET Core Blazor". docs.microsoft.com. Retrieved 2020-11-11.
  8. Roth, Daniel (10 October 2019). "Blazor Server in .NET Core 3.0 scenarios and performance". ASP.NET Blog. Microsoft.
  9. https://devblogs.microsoft.com/aspnet/blazor-webassembly-3-2-0-now-available/
  10. "[Discussion] Updated Blazor browser support for .NET 5 · Issue #26475 · dotnet/aspnetcore". GitHub. Retrieved 2020-11-11.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.