DEV Community

Dave Brock
Dave Brock

Posted on • Originally published at daveabrock.com on

The .NET Stacks #27: Giving some 💜 to under-the-radar ASP.NET Core 5 features

Newsletter image

Note: This is the published version of my free, weekly newsletter, The .NET Stacks. It was originally sent to subscribers on November 23, 2020. Subscribe to get the content right away!

Happy Monday to you all. With .NET 5 out the door and the holidays approaching, things aren’t as crazy. To that end, I wanted to check in on some ASP.NET Core 5 features that might have flown under the radar—and as always, a busy week with our wonderful .NET community.

Giving some 💜 to under-the-radar ASP.NET Core 5 features

As you may have heard, .NET 5 is officially here. Last week, we geeked out with .NET Conf. For .NET web developers, Microsoft is pushing Blazor on you hard. And for good reason: it’s the future of ASP.NET and a game-changer in many ways. Bringing C# to the browser is a big deal.

As a result, Blazor is getting a great deal of the ASP.NET Core 5 attention. It’s important to note that there are still tons of ASP.NET Core developers that aren’t moving to Blazor for a variety of reasons. To be clear, I’m not saying that Microsoft is neglecting these developers—they are not. Also, since Blazor resides in the ASP.NET Core ecosystem, many Blazor-related enhancements help ASP.NET Core as a whole!

However, with all the attention paid to Blazor, a lot of other ASP.NET Core 5 enhancements may have flown under your radar. So this week, I’d like to spend some time this week focusing on non-Blazor ASP.NET Core 5 improvements.

(Also, while it’s very much in flight, the .NET team released the initial ASP.NET Core 6 roadmap for your review.)

⛅ Azure app service supports latest .NET version automatically

You may have noticed that Azure App Service supported .NET 5 on Day 1—meaning when you eagerly downloaded the SDK, you were able to deploy your web apps to Azure App Service. This is thanks to an Early Runtime Feature, which now allows for automatic support of subsequent .NET releases as soon as they’re released. You no longer have to patiently wait for latest-version support.

Before diving in, though, get familiar with how it all works.

🆕 Model binding works with C# 9 record types

With records, immutability is making a big imprint in the C# ecosystem. This can allow you to greatly simplify your need for “data classes”—a big use case is with models that contain properties and no behavior.

ASP.NET Core 5 now can be used for model binding in MVC controllers or Razor Pages. I wrote about it last week. Look at how much simpler I can make things.

Our title bar in action

✅ API improvements

I did discuss this a few weeks ago—and also wrote about it last week—but when you create a Web API project in ASP.NET Core 5 (either from Visual Studio or the dotnet CLI), OpenAPI is enabled by default. This includes adding the Swashbuckle package into your middleware automatically, which allows you to use Swagger UI out-of-the-box. In Visual Studio, just hit F5 to explore your APIs.

Also, the FromBody attribute now supports options for optional properties, and new JSON extension methods can help you write lightweight APIs.

🚀 HTTP/2 and gRPC performance improvements

In .NET 5, gRPC has been given the first-class treatment. If you aren’t familiar, gRPC is a contract-first, open-source remote procedure call (RPC) framework that enables real-time streaming and end-to-end code generation—and leaves a small network footprint with its binary serialization.

With .NET 5, gRPC gets the highest requests per second after Rust. This is thanks to reduced HTTP/2 in Kestrel, improvements with reading HTTP headers, and support for Protobuf message serialization.

We are anxiously awaiting Azure App Service and IIS support. Keep an eye on this GitHub issue for updates.

🔐 AuthN and AuthZ improvements

There’s been quite a few improvements with authentication and authorization.

First, Microsoft has developed a new Microsoft.Identity.Web library that allows you to handle authentication with Azure Active Directory. You can use this to access Azure resources in an easier way, including with Microsoft Graph. This is supported in ASP.NET Core 5.

Joseph Guadagno has written some nice posts on the topic—and as a long-time subscriber of The .NET Stacks, you can trust his judgment. 😉

You can also allow anonymous access to an endpoint, provide custom handling of authorization failures, and access authorization when using endpoint routing.

📦 Container performance enhancements

Before .NET 5, when you published a Dockerfile you needed to pull the whole .NET Core SDK and the ASP.NET Core image. Now, the download size for the SDK is greatly reduced and the runtime image download is almost eliminated (only pulling the manifest). You can check out the GitHub issue to see improvement numbers for various environments.

🌎 Last week in the .NET world

🔥 The Top 3

📢 Announcements

📅 Community and events

😎 ASP.NET Core / Blazor

⛅ The cloud

📔 C# posts

📗 F# posts

🔧 Tools

📱 Xamarin

🏴‍☠️ Other finds

🎤 Podcasts

🎥 Videos

Top comments (0)