What is ASP.NET Core Blazor?

Asked

Viewed 695 times

8

Looking at the list of novelties found in Visual Studio, I came across something talking about ASP.NET Core Blazor, and apparently there’s almost nothing talking about, I found very little material, and in English, but even using the translator was very confused and I could not know what that would be, much less what it does.

  • What would this ASP.NET Core Blazor be, what its purpose and what it does?
  • Does it have anything to do with Razor or ASP.NET Core Razor Pages? (similar names kkk)

2 answers

8


What would this ASP.NET Core Blazor be?

Today only called Blazor, is the engine that takes your C# code and generates a Webassemply. It allows you to use C# code in your browser, as long as it is in the newer versions that already support Webassembly (it will run in older versions with limitations and low performance).

At least it’s the most used form. In fact it has been evolving and there is a way it does without Webassembly, asking the server to deliver certain actions, all in a transparent way. And there are experiments that he doesn’t even need to run in a browser and use bindings not web. But I will not go into all these details.

It is not that C# will run in the browser, there will be a compilation that will generate a code that the browser understands and executes. In a way, it replaces Javascript as the unique language of browsers, although some have not yet understood that this is what happens in practice (the description of the project says that it does not replace the JS, but it is not what happens in practice, of course it does not kill the JS, it is an alternative to replace if the person prefer).

Actually, it’s not just the C, since Blazor gets the IL to generate Webassembly, so it could be other languages that compile for IL.

I just want to make it clear that you cannot take any C# code and it will run on Chrome, FF, Edge, etc. The code needs to be written thinking about being run there. The API is almost all different and has to work with more or less the same things you work with on JS. But much of the Runtime is there to use, so it also doesn’t change that much, but has the limitations of the platform.

There is a form of execution that does not even need to convert IL to Webassembly. Although it is less efficient it has the advantage of running straight. This is possible because the . NET will be running on the same browser runs on any operating system. But I don’t think it’s worth detailing that in this more general question.

It can be especially interesting to facilitate the DRY of validations and other codes that must run on both the server and the client. Or it will be useful for those who do not want to learn more than one programming language and already use C#.

We can say it’s an Angular killer :) And React, Vue and others... Not only he, but "all" languages are landing on the browsers and competing with JS. I say this because Blazor involves the mechanism that transforms C# into Webassembly and the route and navigation system, DOM control and all that frameworks possess. Of course at first he is not so mature, but is evolving fast and already has some innovations, besides having learned from the mistakes of what already exists.

Has some relation to the Razor or ASP.NET Core Razor Pages?

Not directly, but indirectly clear that it does. Razor is for mounting the page on the server, so only the HTML is created, none of the page drawn or executed. Blazor is for the frontend, it runs in the browser, speaking roughly. It uses the same mechanism to render the page in the frontend.

Important that Blazor also exists on the server side so it works basically the same engine but that does not generate Webassembly and is used for cases where the client does not have this capability, for SEO and some other reason that generate the page on the server is better, using basically the same code.

Security

It has not been asked but many people doubt it. Security is the same as JS, it is not able to do anything else in the default browser that JS can. It only does faster and has more powerful libraries, but does not go out creating processes, deleting files or anything that JS cannot without authorization.

Now there’s no more Core in the name.

-3

According to the project documentation:

Blazor uses only the Latest web standards. No plugins or transpilation needed. It runs in the browser on a real . NET Runtime (Mono) implemented in Webassembly that executes normal . NET assemblies. It Works in Older browsers Too by Falling back to an asm.js based . NET Runtime.

that is, they have implemented . net in Webassembly and so their . net programs will run in the browser. In a project generated with Blazor the resulting dll (your Assembly) is loaded into the browser and executed.

More details see on https://github.com/aspnet/blazor

Browser other questions tagged

You are not signed in. Login or sign up in order to post.