Mobile Monitoring Solutions

Close this search box.

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

MMS Founder
MMS Robert Krzaczynski

Article originally posted on InfoQ. Visit InfoQ

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. There is also an improvement 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.

In order 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

Subscribe for MMS Newsletter

By signing up, you will receive updates about our latest information.

  • This field is for validation purposes and should be left unchanged.