What is Blazor and what is Razor

What is Blazor and what is Razor

WHAT IS BLAZOR?

Blazor is a single-page app framework for building interactive client-side Web apps with .NET. Blazor uses open web standards without plugins or code transpilation. Blazor works in all modern web browsers, including mobile browsers.

You write C# in the case of JavaScript, and you can use most of the .NET ecosystem of open source libraries. For the most part, if it's .NET Standard, it'll run in the browser. (Of course, if you called a Windows API or a Linux specific API and it didn't exist in the client-side browser S world, it's not gonna work, but you get the idea).

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.


Following is a great diagram from the Blazor docs.


And Here's the canonical "click a button update some HTML" example.

@page "/counter"
 
<h1>Counter</h1>
 
<p>Current count: @currentCount</p>
 
<button class="btn btn-primary" onclick="@IncrementCount">Count</button>
 
@functions {
    int currentCount = 0;
 
    void IncrementCount()
    {
        currentCount++;
    }
}

You can see this running entirely in the browser, with the C# .NET code running on the client side. .NET DLLs (assemblies) are downloaded and executed by the CLR that's been compiled into WASM and running entirely in the context of the browser.


Note also that I'm stopped at a BREAKPOINT in C# code, except the code is running in the browser and mapped back into JS/WASM world.


Requirements

Please note that if you want to open Blazor projects in Visual Studio, you must have Visual Studio 15.7 Preview 1 or later and the .NET Core 2.1 Preview 1 SDK. Recommended: the latest Visual Studio 2019 Preview and the latest .NET Core SDK.

Note: the Blazor Visual Studio extension is no longer required since the ASP.NET Core Preview 7.

Here is the documentation of Microsoft, Get started with Blazor.

Get started with ASP.NET Core Blazor


Thanks, for reading the blog, I hope it helps you. Please share this link on your social media accounts so that others can read our valuable content. Share your queries with our expert team and get Free Expert Advice for Your Business today.


About Writer

Ravinder Singh

Full Stack Developer
I have 12+ years of experience in commercial software development. I write this blog as a kind of knowledge base for myself. When I read about something interesting or learn anything I will write about it. I think when writing about a topic you concentrate more and therefore have better study results. The second reason why I write this blog is, that I love teaching and I hope that people find their way on here and can benefit from my content.

Hire me on UpWork

Hire me on Linkedin

My portfolio

Ravinder Singh Full Stack Developer