

ASP.NET Core Furthers Minimal API Work in .NET 7 Preview 3
source link: https://visualstudiomagazine.com/articles/2022/04/18/aspnetcore-net-7-preview-3.aspx
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ASP.NET Core Furthers Minimal API Work in .NET 7 Preview 3
- By David Ramel
- 04/18/2022
One of the highlights of improved ASP.NET Core functionality in .NET 6 was support of minimal APIs, for which work is still ongoing in the new .NET 7 Preview 3.
Minimal APIs are architected to create HTTP APIs with minimal dependencies, says Microsoft, which notes they are ideal for microservices and ASP.NET Core apps in which developers want to include only the minimum files, features and dependencies.
In .NET 7 Preview 3 there is new support for route handler filters in minimal APIs, along with improved unit testability for minimal route handlers.
"In this preview, we introduce support for filters in route handlers in minimal applications," said Daniel Roth, principal program manager, in an April 12 blog post. "Filters are executed before the core route handler logic and can be used to inspect and modify handler parameters or intercept handler execution.
"Filters can be registered onto a handler using a variety of strategies. For example, you can register a filter using a RouteHandlerFilterDelegate
and the AddFilter
extension method."
As far as improved unit testability for minimal route handlers, Roth said IResult
implementation types are now publicly available in the namespace Microsoft.AspNetCore.Http
with the suffix HttpResult
(OkObjectHttpResult
, ProblemHttpResult
and so on). He said this helps developers more easily unit test minimal route handlers when using named methods instead of lambdas.
The ASP.NET Core Roadmap for .NET 7 provides more information on what work remains, including for minimal APIs (shown above).
Other highlights of the preview as called out by Roth include:
-
Developer exception page dark mode: Developers can now enjoy a new dark mode when reading about unhandled exceptions:
[Click on image for larger view.] Developer Exception Page Dark Mode (source: Microsoft).
- Bind using
TryParse
in MVC and API controllers: Developers can now bind controller action parameter values using aTryParse
method that has one of two signatures. - New
Results.Stream()
overloads: These are for scenarios where developers need access to the underlying HTTP response stream without buffering. "These overloads also improve cases where your API wants to stream data to the HTTP response stream, like from Azure Blob Storage." - Improved HTTP/2 performance when using many streams on a connection: "We made a change in our HTTP/2 frame writing code that improves performance when there are multiple streams trying to write data on a single HTTP/2 connection. We now dispatch TLS work to the thread pool and more quickly release a write lock that other streams can acquire to write their data. The reduction in wait times can yield significant performance improvements in cases where there is contention for this write lock."
- New
ServerReady
event for measuring startup time: Coders usingEventSource
for metrics/diagnostics who want to measure ASP.NET Core app startup times can now use the newServerReady
event in theMicrosoft.AspNetCore.Hosting
source, which represents the point where the server is up and running.
About the Author
David Ramel is an editor and writer for Converge360.
Recommend
-
16
.NET 5 预览版 8 现在已经可以获取了,并且已经准备好接受评估。下面列出了本次发布的新特性: 使用 Microsoft.Identity.Web 进行 Azure Active Directory 认证 Blazorz 组件的 C...
-
14
ASP.NET Core 6: Working with minimal APIs 2021-08-12 by anthonygiretti Introduction
-
10
ASP.NET Core 6: Minimal APIs, two reasons why I can’t do without it so far 2021-08-27 by anthonygiretti Introduction A f...
-
8
Exploring a minimal WebAPI with ASP.NET Core Sponsored By They are still working on the "dotnet new" templates, but you can...
-
9
0:00 / 1:03:17 ...
-
11
Minimal API-黑暗執行緒 先前展示過用 50 行 Program.cs 寫個 ASP.NET Core CORS 上傳服務,從讀者 Joker 留言我學到新名詞 - Minimal API,身為極簡主義者,它絕對是我的...
-
14
How to test ASP.NET Core Minimal APIs June 07, 2022
-
3
Message-oriented Minimal APIs in ASP.NET Core Published on Sunday,...
-
8
ASP.NET Core Minimal API 整合測試-黑暗執行緒 這篇聊聊 ASP.NET Core 的整合測試。 假設我寫了一個沒啥營養的展示用 Minimal API,其中宣告 GuidServi...
-
9
ASP.NET Core Minimal API Hangfire 設定範例-黑暗執行緒 遇到要寫小工具微服務,我現在幾乎都是用 ASP.NET Core Minimal API 開發,程式碼力求精簡扼要,以符...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK