BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News ASP.NET Core Updates in .NET 9 Preview 4: Support for OpenAPI Doc Generation, HybridCache and More

ASP.NET Core Updates in .NET 9 Preview 4: Support for OpenAPI Doc Generation, HybridCache and More

Microsoft released .NET 9 Preview 4, which contains features regarding ASP.NET Core: built-in support for OpenAPI document generation, HybridCache API, and adding static SSR pages to a globally interactive Blazor Web app. An improvement has also been implemented to avoid 503 errors during an app recycle in IIS.

The OpenAPI specification is a standard for describing HTTP APIs, enabling integration with client and server generators, testing tools, and documentation. In .NET 9 Preview 4, ASP.NET Core includes built-in support for generating OpenAPI documents for both controller-based and minimal APIs using the Microsoft.AspNetCore.OpenApi package. To take advantage of this feature, the mentioned package should be installed in the relevant web project.

dotnet add package Microsoft.AspNetCore.OpenApi --prerelease

ASP.NET Core's built-in OpenAPI document generation includes support for customizations such as document and operation transformers and the ability to manage multiple OpenAPI documents for a single application. More information about these capabilities is available in the Microsoft.AspNetCore.OpenApi documentation.

Furthermore, .NET 9 Preview 4 introduces the new HybridCache API, addressing gaps in the existing IDistributedCache and IMemoryCache APIs and adding features such as "stampede" protection and configurable serialization. HybridCache uses a multi-tier cache storage system, combining a limited in-process cache with a larger out-of-process cache. This approach provides data retrieval from the in-process cache while preventing backend overload for less frequently accessed data. HybridCache is designed to be a drop-in replacement for most IDistributedCache scenarios.

HybridCache includes support for older .NET runtimes down to .NET Framework 4.7.2 and .NET Standard 2.0.

Blazor Web apps can enable global interactivity, allowing all pages in the app to use an interactive render mode: Server, WebAssembly, or Auto. Pages can now opt out of this global interactivity using the new [ExcludeFromInteractiveRouting] attribute. This attribute causes navigations to the page to exit from interactive routing, forcing a full-page reload. Consequently, the top-level App.razor will re-run, enabling a switch to a different top-level render mode.

To avoid 503 errors during an app recycle in IIS, a default one-second delay is now implemented between IIS notification and ASP.NET Core Module (ANCM) initiation of server shutdown. This delay minimizes race conditions between queuing requests to the new app and rejecting requests to the old app. For slower or CPU-heavy machines, adjusting the delay duration via the ANCM_shutdownDelay environment variable or the shutdownDelay handler setting is recommended.

Further details on the new features in this preview can be found in the release notes.

About the Author

Rate this Article

Adoption
Style

BT