The Ultimate Guide to Blazor's Powerful New Capabilities in .NET 9

by Cheyenne Sokkappa, on Jun 16, 2024 5:00:00 AM

.NET 8 was a huge deal for Blazor. It brought us interactive render modes, static SSR for entire apps and a whole lot more. Now, .NET 9 is on the horizon (November 2024 if history is an indication) and while it might not be as flashy, it's definitely packing some serious punches for developers. What's new in Blazor .NET 9? Let's break it down:

dotnet9 and blazor (2)

Custom Rendering Modes, Page by Page

Remember how in .NET 8 we had to choose one rendering mode for the entire app? Well, that's so last year! In .NET 9, we can mix and match rendering modes on a per page basis. So, if you want a lightning -fast SEO-friendly static page here and a super-interactive page there - go for it! This kind of flexibility is a game-changer, and it's way easier to set up with the new ExcludeFromInteractiveRouting attribute.

Blazor Server Gets Even Better

If you're a Blazor Server fan, get ready for a smoother ride. WebSocket compression is enabled by default, meaning your data will zip back and forth faster than ever. Plus, the reconnection experience is way better - no more annoying waits when you navigate back to a disconnected app.

Blazor WebAssembly Authentication Made Easy

Adding authentication to a Blazor WebAssembly project used to be a bit of a headache, but not anymore! New APIs like AddAuthenticationStateSerialization and  AddAuthenticationStateDeserialization are here to save the day. They make managing authentication state between the server and client a breeze.

A Few More Blazor Gifts to Developers

  • Constructor injection: Yep, you can now inject dependencies directly into your components' constructors.
  • Composition events: If you're building apps for international users, the new KeyboardEventArgs.IsComposing property will make your life easier when dealing with complex input methods.
  • QuickGrid OverscanCount: This new parameter gives you more control over the number of rows over your QuickGrid renders when virtualization is enabled. 

Upgrading: Less Pain, More Gain

Moving your Blazor projects from older .NET versions to .NET 9 shouldn't be too much of a hassle. Here's the gist of it:

  1. Update your .NET SDK: Obvs, first things first. Grab the latest .NET 9 SDK and update your global.json file if you have one.
  2. Target framework: Change your project's target framework to net90 in your project files.
  3. Package references: Update your NuGet package references to the latest versions compatible with .NET 9. Microsoft usually makes this super easy.
  4. Breaking changes: While .NET focuses on refinements, it's always wise to glance at the official documentation for any potential breaking changes that might impact your code.

The Future's So Bright, I Gotta Wear Shades

While .NET 9 might not be a massive overhaul, it's clear that the Blazor team is listening to developers and focusing making this whole webdev thing easier. There's still a lot more to come, like improvements to persistent state, prerendering and authentication.

Overall, .NET 9's Blazor updates are like a well-tuned engine; not a radical redesign but a series of refinements that make the whole thing run smoother and more efficiently. Keep an eye on this space - the best is yet to come! 

Shameless plug: we have a bunch of Blazor nerds over here at GAP who are ready to help if you need it. We can upgrade your old stuff or help you build new stuff too.

Talk to an Engineer

Topics:.NETBlazorasp.net.NET 9

Comments

Subscribe to Mobilize.Net Blog

More...

More...
FREE CODE ASSESSMENT TOOL