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 at Converge 360.

comments powered by Disqus

Featured

  • Poisson Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demo of Poisson regression, where the goal is to predict a count of things arriving, such as the number of telephone calls received in a 10-minute interval at a call center. When your source data is close to mathematically Poisson distributed, Poisson regression is simple and effective.

  • 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.

Subscribe on YouTube

Upcoming Training Events