News

What's New for Blazor, ASP.NET Core in Latest .NET 7 Preview

Blazor sports a new WebAssembly loading page and sees improvements to data binding and virtualization in the latest .NET 7 preview.

In that Preview 7, which just shipped yesterday, the dev team showed some love on several fronts for ASP.NET Core's Blazor component, which allows for coding web projects in C# instead of mainly using JavaScript.

For example, the Blazor WebAssembly project template in Visual Studio has a new UI construct that shows the progress of loading an app. The loading screen animation is implemented with two new CSS custom properties -- acting as variables -- that are now part of Blazor WebAssembly, the client-side component of Blazor. They are used to show the percentage of app files loaded and the percentage of app files loaded rounded to the nearest whole number.

"Using these new CSS variables, you can create a custom loading UI that matches the styling of your own Blazor WebAssembly apps," said Microsoft's Daniel Roth in an Aug. 9 announcement post.

New Blazor Loading Page in Animated Action
[Click on image for larger, animated GIF view.] New Blazor Loading Page in Animated Action (source: Microsoft).

Blazor data binding between UI elements or component parameters with .NET objects has also been improved with a new @bind:after modifier that lets a developer execute some async code after a binding event completes.

Two other new modifiers, @bind:get and @bind:set, ease the process of setting up bindings between component parameters and an underlying UI element. "Components can support two-way data binding by defining a pair of parameters for the value and for a callback that is called when the value changes," Roth said.

Also, the dev team tweaked Blazor's Virtualize component, which is used to limit UI rendering to only the currently visible parts, which can be helpful when an app must render a long list of items of which only a subset must be visible at any given time. It uses a spacer element to define the vertical height of the scroll region, being enclosed in a div element by default. Now, for cases in which the parent element doesn't allow child div elements, a new new SpacerElement parameter can be used to configure the spacer element used by Virtualize.

Finally, developers can now pass state when navigating in Blazor apps using the NavigationManager, which enables simple communication between different pages.

Other ASP.NET Core highlights in .NET 7 Preview 7 -- with links for more information -- include:

  • Updated Angular and React templates: see here
  • Improved gRPC JSON transcoding performance and memory usage when serializing messages: see here
  • Authentication will use single scheme as DefaultScheme: see here
  • IFormFile/IFormFileCollection support for authenticated requests in minimal APIs: see here
  • New problem details service for generating consistent problem details responses in an app: see here
  • Diagnostics middleware updates: see here
  • New HttpResults interfaces: see here

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Cloud-Focused .NET Aspire 9.1 Released

    Along with .NET 10 Preview 1, Microsoft released.NET Aspire 9.1, the latest update to its opinionated, cloud-ready stack for building resilient, observable, and configurable cloud-native applications with .NET.

  • Microsoft Ships First .NET 10 Preview

    Microsoft shipped .NET 10 Preview 1, introducing a raft of improvements and fixes across performance, libraries, and the developer experience.

  • C# Dev Kit Previews .NET Aspire Orchestration

    Microsoft's dev team has been busy updating the C# Dev Kit, a Visual Studio Code extension that enhances the C# development experience by providing tools for managing, debugging, and editing C# projects.

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

Subscribe on YouTube

Upcoming Training Events