Blazor WebAssembly by Example
eBook - ePub

Blazor WebAssembly by Example

Toi B. Wright, Scott Hanselman

Condividi libro
  1. 266 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Blazor WebAssembly by Example

Toi B. Wright, Scott Hanselman

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Discover blueprints that explore various components of Blazor, C#, and.NET to help you build web apps without learning JavaScriptKey Features• Explore complete, easy-to-follow web projects using Blazor• Build projects such as a weather app, expense tracker, and Kanban board with real-world applications• Understand and work with Blazor WebAssembly effectively without spending too much time focusing on the theoryBook DescriptionBlazor WebAssembly makes it possible to run C# code on the browser instead of having to use JavaScript, and does not rely on plugins or add-ons. The only technical requirement for using Blazor WebAssembly is a browser that supports WebAssembly, which, as of today, all modern browsers do. Blazor WebAssembly by Example is a project-based guide for learning how to build single-page web applications using the Blazor WebAssembly framework. This book emphasizes the practical over the theoretical by providing detailed step-by-step instructions for each project. You'll start by building simple standalone web applications and progress to developing more advanced hosted web applications with SQL Server backends. Each project covers a different aspect of the Blazor WebAssembly ecosystem, such as Razor components, JavaScript interop, event handling, application state, and dependency injection. The book is designed in such a way that you can complete the projects in any order. By the end of this book, you will have experience building a wide variety of single-page web applications with.NET, Blazor WebAssembly, and C#.What you will learn• Discover the power of the C# language for both server-side and client-side web development• Use the Blazor WebAssembly App project template to build your first Blazor WebAssembly application• Use templated components and the Razor class library to build and share a modal dialog box• Understand how to use JavaScript with Blazor WebAssembly• Build a progressive web app (PWA) to enable native app-like performance and speed• Understand dependency injection (DI) in.NET to build a shopping cart app• Get to grips with.NET Web APIs by building a task manager appWho this book is forThis book is for.NET web developers who are tired of constantly learning new JavaScript frameworks and wish to write web applications using Blazor WebAssembly, leveraging the power of.NET and C#. The book assumes beginner-level knowledge of the C# language, .NET framework, Microsoft Visual Studio, and web development concepts.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Blazor WebAssembly by Example è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Blazor WebAssembly by Example di Toi B. Wright, Scott Hanselman in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Programming in C#. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2021
ISBN
9781800563933
Edizione
1

Chapter 1: Introduction to Blazor WebAssembly

Blazor WebAssembly is Microsoft's new single-page application (SPA) framework for building web applications on .NET Framework. It enables developers to run C# code on the client. Therefore, instead of being forced to use JavaScript on the browser, we can now use C# on the browser.
In this chapter, we will prepare you to develop web applications using Blazor WebAssembly. We will discuss the two different Blazor hosting models and present the advantages of using Blazor WebAssembly over Blazor Server. Finally, we will guide you through the process of setting up your computer to complete the projects in this book.
In this chapter, we will cover the following topics:
  • Benefits of using the Blazor framework
  • Differences between the two hosting models
  • What is WebAssembly?
  • Setting up your PC

Benefits of using the Blazor framework

Using the Blazor framework has several benefits. For starters, it is a free and open source framework built on Microsoft's robust .NET Framework. Also, it is an SPA framework that uses Razor syntax and can be developed using Microsoft's exceptional tooling.

.NET Framework

Blazor is built on .NET Framework. Since Blazor is built on .NET Framework, anyone familiar with .NET Framework can quickly become productive using the Blazor framework. The Blazor framework leverages the robust ecosystem of .NET libraries and NuGet packages from .NET Framework. Also, since both client and server code are written in C#, they can share code and libraries, such as the application logic used for data validation.
Blazor is open source. Since Blazor is a feature of the ASP.NET framework, all of the source code for Blazor is available on GitHub as part of the dotnet/aspnetcore repository that is owned by the .NET Foundation. .NET Foundation is an independent, non-profit organization established to support the innovative, commercially friendly, open source ecosystem around the .NET platform. The .NET platform has a strong community of over 100,000 contributions from more than 3,700 companies.
Blazor is free. Since .NET Framework is free, this means that Blazor is also free. There are no fees or licensing costs associated with using Blazor, including for commercial uses.

SPA framework

The Blazor framework is an SPA framework. As the name implies, an SPA is a web app that consists of a single page. The application dynamically rewrites the single page instead of loading an entirely new page in response to each UI update. The goal is faster transitions that make the web app feel more like a native app.
When a page is rendered, Blazor creates a render tree that is a graph of the components on the page. It is similar to the Document Object Model (DOM) created by the browser. However, it is a virtual DOM. Updates to the UI are applied to the virtual DOM and only the differences between the DOM and the virtual DOM are updated by the browser.

Razor syntax

The name of the Blazor framework has an interesting origin story. The term Blazor is a combination of the word browser and the word razor. Razor is the ASP.NET view engine used to create dynamic web pages with C#. Razor is a syntax for combining HTML markup with C# code that was designed for developer productivity. It allows the developer to use both HTML markup and C# in the same file.
Blazor web apps are built using Razor Components. Razor Components are reusable UI elements that contain C# code, markup, and other Razor Components. Razor Components are quite literally the building blocks of the Blazor framework. For more information on Razor Components, refer to Chapter 2, Building Your First Blazor WebAssembly Application.
Important note
Razor Pages and MVC also use the Razor syntax. Unlike Razor Pages and MVC, which render the whole page, Razor Components only render the DOM changes. One way to easily distinguish between them is that Razor components use the RAZOR file extension, while Razor Pages use the CSHTML file extension.

Awesome tooling

You can use either Microsoft Visual Studio or Microsoft Visual Studio Code to develop Blazor WebAssembly applications. Microsoft Visual Studio is an integrated development environment (IDE), while Microsoft Visual Code is a lightweight, yet powerful, editor. They are both incredible tools for building enterprise applications. Also, they are both available for free and there are versions that run on Windows, Linux, and macOS.
There are many benefits associated with using the Blazor framework to develop web apps. Since it is built on the mature .NET Framework, it enables developers to use the skills, such as C#, and the tools, such as Visual Studio, that they have already mastered. Also, since it is an SPA framework, Blazor web apps feel like native apps.

Hosting models

Blazor has two different hosting models. The first hosting model that Microsoft released is the Blazor Server model. In this hosting model, the web app is executed on the server. The second hosting model that Microsoft released, and the topic of this book, is the Blazor WebAssembly model. In this hosting model, the web app is executed on the browser.
Each hosting model has its own advantages and disadvantages. However, they both use the same underlying architecture. Therefore, it is possible to write and test your code independent of the hosting model. The major differences between the two hosting models concern latency, security, data access, and offline support.

Blazor Server

As we just mentioned, the Blazor Server hosting model was the first hosting model released by Microsoft. It was released as part of the .NET Core 3 release in September 2019.
The following diagram illustrates the Blazor Server hosting model:
Figure 1.1 – Blazor Server
Figure 1.1 – Blazor Server
In this hosting model, the web app is executed on the server and only updates to the UI are sent to the client's browser. The browser is treated as a thin client and all of the processing occurs on the server. When using Blaz...

Indice dei contenuti