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

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...

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 create Whatsapp Click To Chat link

WhatsApp now offers a feature called" Click To Chat " which allow recipient of email to initiate a chat with you with just click of  button or link So how to create a link or a button? WhatsApp now offer  " Click To Chat " feature which allows you to begin chat with someone without having having their number saved in contacts. This feature is very useful for marketing enthusiast. You can add a link with your WhatApp phone number in EDM / Newsletter so that user / recipients can get back to you with a click of a button or link. How do i add button / link to my EDM / Newsletter? You can do so by adding phone number & predefined message to following link https://api.whatsapp.com/send?phone=XXXXXXXXXX&text=My Message will go here You need to remember few thing while creating this link Add phone number without without Zero's 00 or Plus + to start of phone number You also need Encode message of you can encode complete URL   https:/...