Blazor in .NET 8 Previews 6 and 7

Blazor in .NET 8 Previews 6 and 7

The latest releases of .NET 8 Previews 6 and 7 have brought significant adjustments to the ASP.NET framework. The most important enhancements are those associated with Blazor features alongside some great updates regarding improved debugging experience, testing metrics, SPA Visual Studio templates, and more.

What has Blazor now to offer?

Blazor dive-in

Blazor is a framework for building interactive client-side user interfaces, which allows:

  • Creating rich user interfaces in C#
  • Sharing server- and client-side application logic in .NET
  • Rendering UI as HTML and CSS
  • Building reliable, hybrid desktop, web, and mobile applications with .NET

Blazor enjoys great popularity within the programming community, and these are only a few key features worth highlighting:

  1. .NET integration – since it is part of the .NET ecosystem, software developers can use .NET features, which enables code sharing and reuse between server and client
  2. WebAssembly and JavaScript interop:
    • a. The framework can run C# code in the browser directly by using WebAssembly (WASM)
    • b. The framework provides seamless C# and JavaScript interoperation, which allows using existing JavaScript libraries while writing C# code
  3. Modern features – Blazor supports features like Progressive Web Apps (PWA), which allows to build installable, offline-capable web apps using C#, as well as write cross-platform applications by leveraging .NET MAUI
  4. Routing, forms, dependency injection, and more – Blazor provides built-in services and features commonly required in modern web applications, such as client-side routing, form validation, dependency injection, and others

Blazor features 

While JavaScript, just as an example, has long been the conventional standard for front-end web development since inception, software developers have never really seemed to be 100% happy with this scripting language. Conversely, Blazor started showing noticeable potential as a highly productive programming model and became a competitor to the JavaScript frameworks, as well as to Angular, React, and Vue.

Even before .NET 8, Blazor provided great features that enhanced productivity, performance, and flexibility:

  1. Zero restrictions with HTML and CSS:

Blazor offers the flexibility to use any HTML and CSS, which allows software developers to craft user interfaces as they would with any other modern application, leveraging any CSS framework or library they prefer.

  1. Server-side prerendering

Blazor also allows components to be seamlessly rendered on the server side during the initial request. 

  1. Hot reload

Hot reload allows engineers to see code changes in real-time without needing to refresh or restart the app.

  1. Lazy loading

Lazy loading enables applications to defer the loading of assemblies or components until they are required.

.NET 8 Preview 6 Blazor updates

.NET 8 Preview 6, announced on July 11th this year, revealed new Blazor updates, in particular:

Server-side rendering 

  • Server-side rendered page components can provide similar experience to Razor Pages or MVC apps – each page is going to be processed and rendered on the web server, once all operations to collect data and execute logic have completed, then the HTML produced will be sent to the browser to be rendered
  • Another feature worth mentioning – software developers can now intercept requests and utilize obtained responses for the existing DOM, which ensures fluid experience in single-page apps (SPAs) when leveraging server-side rendering

Streaming rendering

  • The update allows pages executing long running requests to be quickly loaded via initial HTML payload – HTML can contain placeholders for areas to be further filled with results of the running call, and once it’s completed, the remaining HTML code is streamed to the browser directly and patched into existing DOM elements
  • The @rendermode directive attribute allows choosing render modes for specific component instances

Interactive rendering 

  • Blazor WASM introduced support for interactive component rendering (through not yet part of the default template, software developers can enable it manually)
  • A provided demo illustrates how to establish interactivity by WebAssembly for a Counter component within an Index page, which showcases how WebAssembly can enhance a web Blazor app

Section and feature interactions

Several changes were made to enhance how different Blazor sections interact with its features:

  • Now, values flow into section content from where they’re defined, not where they’re rendered within a section outlet
  • Unhandled exceptions are now being addressed by the error boundaries that surround section content, not the section outlet
  • Whether the section content is using streaming rendering is determined by components that define section content, not those that establish section outlet

.NET 8 Preview 7 Blazor updates

.NET 8 Preview 7, announced on August 8th this year, revealed fresh Blazor enhancements, in particular:

Antiforgery protection

  • Starting with this release, Blazor enforces default endpoint antiforgery protection 
  • In this latest version, Blazor framework’s EditForm component will incorporate an automatic antiforgery token (software developers will have the choice to disable this functionality, but it’s strongly discouraged due to security considerations)

Form creation

No constraints associated with Blazor EditForm when using server-side rendering while building HTML forms. You can now conveniently craft standard HTML forms, which offers more flexibility.

Auto interactive render mode

This mode blends both Server and WebAssembly modes to provide more smooth rendering experiences. 

Cascading values

With this latest addition, cascading values being registered at the root level become accessible throughout the component hierarchy, naturally making data sharing across components more straightforward.

Summing up

From the very outset, Blazor has established itself as a promising solution for web application development. And today, it’s gaining more and more momentum.

The upcoming .NET 8, set for release in November 2023, is promising to surprise us with long-awaited features. No wonder the release blog post got so many reactions, with users actively engaging in discussions related to the perspectives of the coming updates. 

Abto Software, with great Blazor expertise, can serve large industries, including healthcare and government, delivers scalable B2B and B2C portals, ERPs, CRMs, enterprise-level applications, hybrid solutions, and more. Our teams cover everything from planning, product design, and prototyping to deployment and maintenance.

Our services:

Contact us to handle:

  • Blazor web application development
  • Blazor integration services
  • Blazor migration services
  • Progressive web application (PWA) software development

And leverage business modernization:

  • Seamless integration with existing .NET infrastructure
  • Code sharing and reuse
  • Rich tooling
  • Optimized productivity, business performance, and flexibility

Contact us

Tell your idea, request a quote or ask us a question