The Latest Features in Blazor .NET 8

Author: Inza Khan

22 August, 2024

.NET released .NET 8 on November 14th, 2023, and it significantly improved the Blazor framework, making it a comprehensive web UI tool. Developers can now use Blazor to create interactive web applications using C# and .NET instead of traditional JavaScript. 

A notable feature in Blazor .NET 8 is Server Side Rendering (SSR), improving web app performance by generating static HTML on the server for faster load times. It combines server-side rendering with interactive components for quicker initial page loads and supports Interactive WebAssembly Rendering for creating client-side interactive components with server-side prerendering. Interactive Auto Rendering optimizes app startup by intelligently using both server-side and client-side runtimes. 

Alongside these improvements, Blazor .NET 8 enhances developer experience with better performance options, increased rendering flexibility, and simplified integration using C# and .NET. The update also brings improved tools and functionality to ASP.NET Core, including new JavaScript features for customizable loading in different app types. Features, like keyed service injection and rendering Razor components outside HTTP requests, add flexibility and utility to application development, emphasizing a focus on stable functionality with better modularity and error resolution. 

Latest Features in Blazor .NET 8

Blazor .NET 8 Full-Stack Web UI Capabilities 

Blazor in .NET 8 introduces full-stack web UI capabilities, enabling developers to craft applications that render content at various levels, whether it’s at the component or page level. The framework offers three distinct rendering modes: 

  • Static Server Rendering: Also known as static server-side rendering (static SSR), this mode generates static HTML on the server, enhancing performance and SEO while delivering a fast initial page load experience. 
  • Interactive Server Rendering: This mode, also referred to as interactive server-side rendering (interactive SSR) or streaming rendering, combines server-side prerendering with interactive components, striking a balance between interactivity and performance. 
  • Interactive WebAssembly Rendering: With interactive client-side rendering (CSR), interactive components are generated on the client side, leveraging WebAssembly for enhanced interactivity while still benefiting from server-side prerendering for SEO and performance optimization. 
  • Interactive Auto Rendering: This mode intelligently selects the most suitable rendering approach based on the runtime environment, ensuring optimal performance and user experience. It utilizes server-side ASP.NET Core runtime for initial rendering and seamlessly transitions to client-side rendering using .NET WebAssembly runtime for subsequent interactions. 

Blazor Web App Template 

.NET 8 introduces the Blazor Web App template, a new project template designed to streamline the development of Blazor web applications. This template amalgamates the strengths of existing Blazor Server and Blazor WebAssembly hosting models while incorporating new capabilities introduced in .NET 8, such as static SSR, streaming rendering, enhanced navigation, and form handling. By offering a unified starting point for building web UIs with Blazor components, this template simplifies project setup and accelerates development workflows. 

Consolidation of Project Templates 

As part of unifying various Blazor hosting models into a single model in .NET 8, the number of Blazor project templates has been consolidated. The Blazor Server template has been removed, and the ASP.NET Core Hosted option is no longer available in the Blazor WebAssembly template. Instead, developers can choose from different scenarios within the Blazor Web App template, catering to diverse project requirements and preferences. 

Refined Tooling and Project Structure 

In .NET 8, tooling and project structure for ASP.NET Core Blazor applications have been refined. These improvements are reflected in updated documentation, offering developers guidance on project organization and rendering modes. The refined tooling enhances the development experience, making it more intuitive and efficient. 

New JavaScript Initializers for Flexibility 

Blazor Web Apps in .NET 8 now leverage a new set of JavaScript initializers, providing developers with enhanced flexibility for customizing the loading process. The beforeWebStart and afterWebStarted initializers offer a gateway for tasks such as customizing the loading process, logging level, and other configuration options. This increased customization capability empowers developers to tailor the application’s behavior according to specific requirements, enhancing the overall user experience. 

Form Handling and Model Binding Advancements 

Blazor components in .NET 8 gain the ability to handle submitted form requests, supporting model binding and data validation. The introduction of new anti-forgery support ensures secure form submissions, enhancing the overall security posture of Blazor applications. 

Enhanced Navigation, Streaming Rendering, and More 

Static server-side rendering in .NET 8 brings about enhanced navigation and form handling. Blazor .NET 8 now intercepts requests and performs fetch requests, resulting in faster and smoother page loads. Streaming rendering is introduced, enabling content updates to be streamed on the response stream during static server-side rendering with Blazor, thereby improving the overall user experience. 

Keyed Service Injection and HttpContext Access 

In a move towards greater flexibility and control, Blazor .NET 8 now supports injecting keyed services using the [Inject] attribute. Additionally, developers can access the current HttpContext as a cascading parameter from a static server component, opening new possibilities for handling context-specific scenarios in Blazor applications. 

Sections Support, Error Page Improvements, and Graduation of QuickGrid 

The introduction of SectionOutlet and SectionContent components brings support for specifying outlets for content that can be filled in later, enhancing modularity in Blazor applications. Error page support is improved in Blazor Web Apps in .NET 8. Additionally, the experimental Blazor QuickGrid component graduates to an official part of the Blazor framework, providing a powerful tool for building dynamic and responsive data grids. 

Client-Side Routing Enhancements and Root-Level Cascading Values 

Blazor in .NET 8 supports using client-side routing to navigate to a specific HTML element on a page using standard URL fragments, enhancing navigation capabilities. Root-level cascading values, registerable for the entire component hierarchy, are introduced, offering a centralized approach to manage shared values across components. 

Blazor vs. Razor 

Razor: Combining Code and Markup 

Razor, a markup syntax for .NET, is commonly used in ASP.NET for blending C# code with HTML. It smoothly handles the rendering of dynamic content based on model data, making web page creation straightforward and efficient. 

Blazor: The Next Step in .NET Web Framework 

Blazor, an evolution in the .NET ecosystem, goes beyond Razor. It stands for Browser + Razor and acts as a web framework, allowing applications to run on the client with WebAssembly or on the server using SignalR. Despite some confusion, Blazor doesn’t use Razor directly. Instead, it relies on Razor components, where HTML markup and C# logic come together in a single .cshtml file. 

Conclusion 

The release of .NET 8 brings significant advancements to Blazor, a web framework in the .NET ecosystem. As a Long Term Support (LTS) release, .NET 8 ensures stability for long-term projects and its notable features include improved documentation, addressing common challenges, and introducing practical tools like the Blazor Web App template for streamlined development. 

The new JavaScript initializers enhance customization options, while the consolidation of project templates simplifies project setup. Client-side routing enhancements and support for sections provide flexibility for developers. Overall, .NET 8 with Blazor stands as a reliable and efficient framework, shaping the landscape of modern web development.

Read more on related topics: 

  1. Why Switch to .NET 8 in 2024? 
  2. The Evolution of .NET: A Comprehensive Overview of its Role in Modern Software Development. 
  3. .NET Framework vs .NET: Technical Considerations for Application Development and Migration. 

Reach out to us for expert guidance and assistance in leveraging the power of .NET 8 and Blazor for your software development projects.

Top Features to Look for in Manufacturing Custom ERP Software
Tips to Find a Managed Services Provider in Milwaukee
Mobile App Development for Communities
Teams Integrated AI Chatbot

Let’s Start a Conversation

Request a Personalized Demo of Xorbix’s Solutions and Services

Discover how our expertise can drive innovation and efficiency in your projects. Whether you’re looking to harness the power of AI, streamline software development, or transform your data into actionable insights, our tailored demos will showcase the potential of our solutions and services to meet your unique needs.

Take the First Step

Connect with our team today by filling out your project information.

Address

802 N. Pinyon Ct,
Hartland, WI 53029