The .NET Stacks #27: Giving some 💜 to under-the-radar ASP.NET Core 5 features
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 at the bottom of this post 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.
✅ 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
- Mika Dumont provides an update on .NET productivity (Roslyn).
- The .NET Docs Show talks to Irina Scurtu about REST in .NET.
- Abel Wang continues writing about pulling off a Static Web App PR workflow for Azure App Service using Azure DevOps.
📢 Announcements
- GitHub accounts are now integrated into Visual Studio 2019.
- Microsoft has released WinUI 3 Preview 3.
- GitHub Desktop now has split diffs.
- AWS announces end of support for the AWS SDK for .NET version 2.
- Jon Douglas introduces NuGet 5.8.
- Clément Habinshuti introduces the OData Web API authorization library.
- Jimmy Bogard updates his vertical slice example to .NET 5.
📅 Community and events
- The Overflow writes about the complexities and rewards of open sourcing corporate software products.
- For community standups this week, Tooling talks to Stephen Toub about .NET 5 performance, Entity Framework has an EF Core 5 community panel, and ASP.NET talks about bUnit with Egil Hansen.
- The .NET Foundation wants your feedback, and there might be prizes involved.
😎 ASP.NET Core / Blazor
- Dave Brock (hi!) simplifies ASP.NET Core API models with C# 9 records, and also works with OpenAPI, Swagger UI, and HttpRepl in ASP.NET Core 5.
- The Code Maze blog sends an SMS with ASP.NET Core.
- Khalid Abuhakmeh resolves multiple types in ASP.NET Core.
- Imar Spaanjaars uses standard health checks in ASP.NET Core, and also unit tests authorization on controllers.
- Marinko Spasojevic writes about localization in Blazor WebAssembly apps, and also works with Blazor WebAssembly component virtualization.
- Kristoffer Strube calls anonymous C# functions from JS in Blazor WebAssembly.
- Shaun C. Curtis offers an alternative to routing in Blazor.
- Ricardo Peres discusses pitfalls when returning a custom service provider from ConfigureServices.
- Mark Heath uses OpenAPI auto-generated clients in ASP.NET Core.
- Roland Weigelt compares SignalR in .NET Core 3.1 vs. .NET 5.
⛅ The cloud
- Damien Bowden uses the Microsoft Graph API in ASP.NET Core.
- Azure Tips & Tricks writes about which database to use in your next Azure Functions app.
- Mark Heath writes about simple messaging with Rebus and Azure Storage queues.
- Joe Guadagno adds .NET 5 support to Azure App Service.
- Niels Swimberghe queries top requested URL’s using Kusto and Log Analytics in Azure Application Insights .
- David Hayden publishes an ASP.NET Core Web API to Azure API Management.
📔 C# posts
- Konrad Kokosa writes about 6 less popular facts about C# 9 records.
- David Hayden writes about recursive Fibonacci and memoization in C#.
- Patrick Smacchia explains C# index and range operators.
📗 F# posts
- Timothé Larivière writes about Fabulous.
- Alican Demirtas writes about
nameof
support in F# 5. - Angel Munoz writes about monoliths in F# and JS, as well as working with Giraffe.
🔧 Tools
- Matt Lacey gets festive with Visual Studio Extensions.
- Derek Comartin talks about the complexity of caching.
- David Walsh removes untracked files in Git.
- Scott Hanselman asks you to update dotnet-outdated because it’s outdated.
- Mark Seemann redirects legacy URLs.
- Andrew Lock offers tips, tricks, and edge cases when deploying to k8s.
- Khalid Abuhakmeh works with Uno Platform and Rider.
📱 Xamarin
- Benjamin Askren says goodbye to Xamarin.Forms.
- Leomaris Reyes works with experimental flags.
🏴☠️ Other finds
- David McCarter says the “full-stack” developer is a myth.
- The API Evangelist uses API mocks as part of an API-first workflow.
🎤 Podcasts
- The Software Engineering Daily podcast talks about GraphQL at GitHub with Marc-Andre Giroux.
- The .NET Rocks Podcast talks with Aaron Stannard about Microsoft open source.
- On Software Engineering Radio, Julie Lerman talks about ORMs and EF.
- The Merge Conflict podcast discusses .NET Conf and the Apple M1 event.
🎥 Videos
- The Visual Studio Toolbox discusses the .NET object allocation tracking tool.
- Brian Lagunas fixes an issue with Blazor drop-down not working with InputSelect.
- The Azure Enablement series introduces the Cloud Adoption Framework for Azure.
- Jeff Fritz talks about new features in C# 9.
- ON.NET talks about service discovery with Steeltoe, and also Steeltoe and Azure Spring Cloud.