News

What's New for ASP.NET Core and Blazor in Final Preview of .NET Core 3.0

Improved gRPC functionality is just one many new improvements in the ASP.NET Core component of .NET Core 3.0 Preview 9, the last step before the entire .NET Core 3.0 platform hits general availability in about three weeks.

Many Microsoft-centric developers were up in arms about the company's decision to abandon Windows Communication Foundation (WCF) -- part of the traditional .NET Framework -- in the move to.NET Core in favor of other mechanisms such as gRPC (Google's open source take on remote procedure call systems).

Microsoft earlier this year said, "If you are a remoting or WCF developer and want to build a new application on .NET Core, we would recommend either ASP.NET Core Web APIs or gRPC (Google RPC, which provides cross platform and cross programming language contract based RPCs)."

To that end, the final .NET Core 3.0 preview boosts gRPC functionality in the ASP.NET Core component. Preview 9 sports a new client API for gRPC and features support for async streams in streaming gRPC responses.

"To improve compatibility with the existing Grpc.Core implementation, we've changed our client API to use gRPC channels," said Daniel Roth, principal program manager for ASP.NET, in a Sept. 4 blog post. "The channel is where gRPC configuration is set and it is used to create strongly typed clients. The new API provides a more consistent client experience with Grpc.Core, making it easier to switch between using the two libraries."

Furthermore, Roth said, "gRPC streaming responses return a custom IAsyncStreamReader type that can be iterated on to receive all response messages in a streaming response. With the addition of async streams in C# 8, we've added a new extension method that makes for a more ergonomic API while consuming streaming responses."

Blazor, the red-hot project recently graduated from experimental stage that lets developers use C# in Web projects instead of (or in addition to) JavaScript, thanks to WebAssembly, received several routing improvements in this preview, including the abilities to:

  • Render content using a specific layout
  • Routing decoupled from authorization
  • Route to components from multiple assemblies

Other improvements in Preview 9 listed by Roth include:

  • Blazor event handlers and data binding attributes moved to Microsoft.AspNetCore.Components.Web: "In this release we moved the set of bindings and event handlers available for HTML elements into the Microsoft.AspNetCore.Components.Web.dll assembly and into the Microsoft.AspNetCore.Components.Web namespace."
  • Render multiple Blazor components from MVC views or pages: "We've reenabled support for rendering multiple components from a view or page in a Blazor Server app. To render a component from a .cshtml file, use the Html.RenderComponentAsync(RenderMode renderMode, object parameters) HTML helper method with the desired RenderMode."
  • Smarter reconnection for Blazor Server apps: "Blazor Server apps are stateful and require an active connection to the server in order to function. If the network connection is lost, the app will try to reconnect to the server. If the connection can be reestablished but the server state is lost, then reconnection will fail. Blazor Server apps will now detect this condition and recommend the user to refresh the browser instead of retrying to connect."
  • Utility base component classes for managing a dependency injection scope: "In ASP.NET Core apps, scoped services are typically scoped to the current request. After the request completes, any scoped or transient services are disposed by the dependency injection (DI) system. In Blazor Server apps, the request scope lasts for the duration of the client connection, which can result in transient and scoped services living much longer than expected."
  • Razor component unit test framework prototype: "We've started experimenting with building a unit test framework for Razor components. You can read about the prototype in Steve Sanderson's Unit testing Blazor components – a prototype blog post."
  • Helper methods for returning Problem Details from controllers: "Problem Details is a standardized format for returning error information from an HTTP endpoint. We've added new Problem and ValidationProblem method overloads to controllers that use optional parameters to simplify returning Problem Detail responses."

All of the above and more is detailed in the blog post and the release notes.

The official general availability release of .NET Core 3.0 is scheduled for the online virtual event, .NET Conf, to be held Sept 23-25.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube