logo
logo
Sign in

Blazor in .NET 8 Previews 6 and 7

avatar
Liam Grant
Blazor in .NET 8 Previews 6 and 7

This post is a quick overview of an Abto Software blog article.


With recent Blazor iterations – .NET 8 Previews 6 and 7 – great changes were made to the ASP.NET framework. The most central transformations are adjustments mainly surrounding Blazor functionality, coupled with significant advancements in debugging, testing metrics, SPA Visual Studio templates, and others.


So now, what can we expect? 


Blazor 101: Everything you should know

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

  • Developing sophisticated user interfaces using C#
  • Sharing server- and client-side application logic in .NET
  • Converting UI to HTML and CSS for rendering
  • Crafting dependable hybrid applications for desktop, web, and mobile platforms using .NET


Blazor enjoys great popularity within the programming community, and not without reason:

  • .NET integration: Blazor utilization, as it is an integral part of the .NET ecosystem, might provide software developers with capabilities that facilitate code sharing and reuse between server and client
  • WebAssembly and JavaScript interaction:

a. By leveraging WebAssembly (WASM), the framework can execute C# code directly within the browser

b. As seamlessly, Blazor provides C# and JavaScript interoperability, thus allowing the utilization of existing JavaScript libraries along with C# development

  • Modern functionalities: Blazor embraces modern concepts – for example Progressive Web Apps (PWA) – and enables the creation of installable web applications with convenient offline capabilities 
  • Routing, forms, dependency injection, and beyond: Blazor provides built-in services and functionalities for building web applications, for example client-side routing, form validation, dependency injection, and more


Blazor features that make the difference

While JavaScript has historically typically served as the primary standard for front-end web development, software developers utilizing JavaScript haven’t expressed sincere enthusiasm about this scripting language. Conversely, Blazor has emerged as a compelling alternative, showcasing productivity and outperforming established frameworks, including Angular, React, Vue, and others.


Some features present before .NET 8 worth mentioning:


1. Zero restrictions with HTML and CSS:

Blazor provides the flexibility to utilize both HTML and CSS, which enables software developers to create appealing interfaces, as they would normally with any other application by leveraging the library or framework they prefer.


2. Server-side prerendering

Blazor provides the opportunity to render the components on the server side during the initial request.


3. Hot reload

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


4. 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 offer comparable experiences to Razor Pages or MVC apps. Each page undergoes processing and rendering on the web server, and once data collection along with logic execution are complete, the resulting HTML code is sent for rendering.
  • What’s more, software developers can now intercept requests and use acquired responses for the existing DOM, which facilitates seamless experience in single-page apps (SPAs) when utilizing server-side rendering.


Streaming rendering

  • This update enables pages that have long-running requests to load swiftly via the initial HTML payload. HTML may include placeholders for areas awaiting results from requests, and once they’re completed, the remaining HTML code is streamed 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
  • 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
  • Unhandled exceptions are now being addressed by the error boundaries that surround section content
  • Whether the section content is using streaming rendering is determined by components that define section content


.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 .NET 8 Preview 7, Blazor enforces default endpoint antiforgery protection
  • In this latest version of the .NET 8, Blazor EditForm will incorporate an automatic antiforgery token


Form creation

No constraints associated with Blazor EditForm when using server-side rendering while building HTML forms. That means software developers can create HTML forms without limitations, thus enjoying greater flexibility. 


Auto interactive render mode

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


Cascading values

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.


Why wait to discover new opportunities?


Abto Software, having profound Blazor knowledge & experience, is helping business leaders across industries. Our company covers everything from web application development, integration, as well as migration services, to handling progressive web application (PWA) software development.


We empower business leaders to leverage seamless integration with existing .NET infrastructure, rich tooling, optimized productivity, greater performance, and flexibility.



collect
0
avatar
Liam Grant
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more