It turns out that the Linux desktop written by .NET is so beautiful?

How to run the program Blazorunder Linuxthe platformDesktop

This article will explain how to use Blazorand run cross-platform applications. The technologies applied are as follows

Used to verify cross-platform and whether to improve development efficiency, the technology used by Blazor and Photino is called Blazor Hybrid,

Advantages of Blazor

Blazor is an emerging technology for building client-side web applications using .NET and C#. It allows developers to run .NET code directly in the browser without relying on JavaScript. The technical advantages of Blazor are mainly manifested in the following aspects:

  1. Single language stack : Blazor allows developers to use C# and .NET for full-stack development. Having one language for frontend and backend can greatly simplify the development process, reduce errors and increase efficiency. There is no longer a need to switch back and forth between JavaScript and C#, which reduces the complexity and potential for errors in context switching. In contrast, traditional web development requires the use of multiple languages ​​such as JavaScript, HTML, and CSS, and JavaScript does not have strong typing features, so it is more error-prone.

  2. Runs on WebAssembly : Blazor uses WebAssembly (Wasm) technology to run .NET code in the browser. WebAssembly is a low-level language that runs in modern browsers, which is closer to machine language than JavaScript, so it runs faster. Moreover, the execution environment of WebAssembly in the browser is sandboxed, which means that it can be executed safely without affecting other system resources.

  3. Strong Type Checking : Blazor uses C#, which is a strongly typed language. Compared with JavaScript, strongly typed languages ​​can catch more errors at compile time and reduce the possibility of errors at runtime. At the same time, strongly typed languages ​​can provide better auto-completion, refactoring, and smart prompt functions, which can greatly improve development efficiency.

  4. Reuse code and library : Since Blazor uses .NET, you can share the same data model and business logic code on the front-end and back-end, avoiding a lot of duplication of work due to synchronizing the front-end and back-end codes. In addition, .NET's library ecosystem is very rich, which means that you can directly use a large number of existing libraries and frameworks in Blazor applications without modifying them.

  5. Component architecture : Blazor adopts a component design pattern, which allows you to create reusable UI components and improve code readability and maintainability. A componentized architecture also makes testing easier because each component is self-contained and can be tested individually.

  6. Compatibility with existing technologies : Blazor is not exclusive to other web technologies. You can use JavaScript and JavaScript libraries in Blazor applications, and you can embed Blazor components into existing MVC or Razor Pages applications. This compatibility makes Blazor more flexible and can adapt to various complex needs.

  7. Modern development experience : Blazor supports hot reloading, which allows you to see the effect in the browser immediately after saving code changes, without manually refreshing the page. This greatly improves development efficiency, allowing developers to iterate and debug quickly. In addition, Blazor also supports the use of SignalR for real-time communication, making it easier to create real-time web applications.

  8. Support from Microsoft : As a technology launched by Microsoft, Blazor has received strong technical support. Microsoft provides comprehensive documentation for Blazor, enabling developers to quickly learn and master this technology. Additionally, Microsoft regularly releases updates to enhance Blazor functionality, improve performance, and fix issues. Strong community support is also a major advantage of Blazor. Developers can seek help, share experiences or participate in project contributions in the community.

  9. Cross-platform support : Blazor apps can run on any browser that supports WebAssembly, which means it has excellent cross-platform compatibility. You can use Blazor to develop desktop, mobile and web applications without writing different code for different platforms.

  10. Security : Blazor supports secure authentication and authorization mechanisms such as ASP.NET Core Identity and OAuth 2.0. You can easily add security measures to your application to protect user data and application resources.

  11. Extensibility : Blazor's design allows developers to create custom components, middleware, and services to meet specific needs. This makes Blazor highly scalable and can adapt to various complex application scenarios.

  12. Progressive Web App (PWA) support : Blazor supports the creation of Progressive Web Apps (PWA), which means you can create web apps that can run offline and behave like native apps. PWAs have many advantages in terms of performance, accessibility, and user experience, making them more and more popular among developers and users.

  13. Server-Side Blazor (Blazor Server) : Blazor also provides a server-side rendering mode called Blazor Server. In this mode, all the logic of the Blazor application runs on the server, and the browser is only responsible for displaying the UI. This makes the application start faster, while reducing the burden on the client. Blazor Server implements real-time communication through SignalR to ensure that the UI is synchronized with the server state.

    In summary, Blazor, as a technology for building client-side web applications using .NET and C#, has many significant advantages, including a single language stack, WebAssembly support,

start usingMasa Blazor

Start our first step, install Masa Blazorthe template, please pay attention to the template version 1.0.0-rc.2, only 1.0.0-rc.2the new project template

dotnet new install Masa.Template::1.0.0-rc.2

image.png

After the installation is complete, we found Masa Blazorthat templates for basically all platforms of .NET are provided. Of course, we only explain in this articlePhotino

Alright, let's move on to creating the project template. Open vs and we will find that MASAthere are many project templates below. We create the first one Masa Blazor Photino App(MASA), then create the project with the default option, and then start the project.

image.png

This is a default template provided

image.png

It runs normally under win, and then we want to try whether it can run normally under Linux, ready to release the project, right click on our 项目=> 发布=>文件夹
image.png

Since my Ubuntusystem is not installed SDK, I will release 独立the mode! Then move the deployment file to Ubuntu,
image.png

Then open the console in the current directory

Give the program executable permissions, then run the project

sudo chmod +x MasaBlazorApp1
./MasaBlazorApp1

image.png

This is the effect of operation. This is the easiest way. Below I Masa Promigrate the provided code to the current Demo and Linuxrun it in

The following is Windowthe effect of the transplant in operation
image.png

, then continue as before, publishing Linuxthe app, then running the
image.png

A super nice Linuxdesktop program is written, very simple, the project address is placed at the bottom

Sharing from token

Technical exchange group: 737776595

Project address: https://github.com/239573049/Photino.Masa.Blazor.Pro

Sponsored by Masa Blazor (Happy Fat House Water)

Guess you like

Origin blog.csdn.net/xiaohucxy/article/details/130737154
Recommended