Skip to main content

What is C# Blazor?

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:
  • 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
Blazor can run your client-side C# code directly in the browser, using WebAssembly. Because it's real .NET running on WebAssembly, you can re-use code and libraries from server-side parts of your application.  example below for reference

@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.
link for installation: https://devblogs.microsoft.com/aspnet/blazor-now-in-official-preview/
https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=visual-studio

Comments

Popular posts from this blog

Japanese new era date - 日本の新時代の日付

Since April 1, 2019, the new era name was announced for Japanese date Reiwa (令和). I came across few question by programmers regarding Japanese date and most of it was showing old era as not all user had updated their operating systems libraries. On April 25, Microsoft released packages for different Windows operating systems containing the updated registry key with the new era name. Update your device and check your registry to see if it has the new key, and then test your application. The Japanese calendar is divided into eras, and for most of the modern age of computing, system have been in the Heisei era; however, on May 1, 2019, a new era began Reiwa (令和). Because this is the first time in decades for an era to change, software that supports the Japanese calendar will need to be tested to ensure it will function properly when the new era begins. In the following sections, you will learn what you can do to prepare and test your application for the upcoming new era. ...

How to unblock your website on Facebook within 24 hours - unblock Facebook share

We recently noticed that one of our website was blocked by Facebook and we where not able to share any post on facebook.com and every time we tried to post on Facebook we used to get this message After reading tones of post and Facebook Help Centre, it was not very clear what caused this block our website which is related to company didn't violate any Community Standards. So our guess was that somebody maliciously reported our website as spam which resulted in block or it was false positive on Facebook side. How did we resolve it & action taken from our side. Step1 (didnt work) : First thing we did was to report it to Facebook using the link "Let us Know" which showed on error message when sharing any post from our website. This was not of much help as Facebook doesn't reply quickly or at all based on the feedback i got from forums, blogs & Facebook forums it self. Step 1 could work if Facebook can't get back & resolve the issue as false...

Microsoft Blazor / ASP.Net Core video Collection Tutorials

Video Collection related to Microsoft Blazor What is .Net? | .Net ASP.NET Core 101 - Series by Scott Hanselman & Kendra Havens This tutorial explains what is .NET anyway? .NET is an open source development platform which is just a way of saying it's a collection of languages and libraries that can all work together to build all kinds of apps! Entire Series here   ASP.NET Core - Beginner - 3.1 Razor Pages Whats new in ASP.NET Core 3.1 Preview 1 for Blazor. In this video we'll update our Blazor Application to use ASP.NET Core 3.1 Preview 1. Also, we'll explore the new features of this version of .NET Core. Blazor, a new framework for browser-based .NET apps - Steve Sanderson Today, nearly all browser-based apps are written in JavaScript (or similar languages that transpile to it). That’s fine, but there’s no good reason to limit our industry to basically one language when so many powerful and mature alternate languages and programming ...