.NET 9 Improvements for ASP.NET Core: Open API, Performance, and Tooling
Roshan
Posted on November 16, 2024
With the release of .NET 9, ASP.NET Core has reached new heights, delivering powerful improvements in Open API support, performance optimization, and developer tooling. These advancements make it the most capable and efficient version yet, catering to developers building modern, high-performance web applications.
Let’s explore the key enhancements introduced in .NET 9 for ASP.NET Core.
1. Open API Enhancements
.NET 9 introduces significant updates to the Microsoft.AspNet.Core.OpenApi
package, providing enhanced Open API support for ASP.NET Core applications. Two new APIs were introduced:
-
add OpenAPI
: Registers Open API services with the dependency injection container, enabling customization of the Open API experience. -
map OpenAPI
: Exposes an endpoint that returns the Open API document in JSON format.
These updates enable seamless integration with tools such as:
Swagger UI
The new Swashbuckle.AspNetCore
package bundles Swagger UI, allowing developers to:
- Visualize and interact with API endpoints, schemas, and data models.
- Generate client code for various targets, including cURL, Python, and C#.
- Test API requests directly from the UI.
Bruno
Bruno, another tool in the ecosystem, supports API testing using Open API documents. It offers:
- A scripting API for programmatic test data generation.
- Advanced testing capabilities for complex API scenarios.
These enhancements empower developers to streamline API design, documentation, and testing processes.
2. Performance Improvements
.NET 9 is the fastest ASP.NET Core release to date, bringing notable performance enhancements:
- Higher throughput with reduced memory consumption: Improvements in garbage collection have led to significant gains.
- Blazor WebAssembly Apps: Faster startup times ensure smoother user experiences.
- Blazor Server Apps: WebSocket message compression improves responsiveness.
- Optimized static web asset delivery: Features like automatic pre-compression and file fingerprinting result in efficient downloading and caching.
Static Asset Optimization Example
A new map static assets
API replaces the older use static files
middleware. This API optimizes static file delivery during the build and publish phases:
- File Fingerprinting: Adds a content-based hash to filenames for aggressive caching.
- Pre-Compression: Pre-compresses static files using Brotli during publishing, reducing server workload and runtime file sizes.
- Faster Page Loads: Optimized files are efficiently downloaded and cached, enabling near-instantaneous page loads on repeat visits.
These performance enhancements make .NET 9 a game-changer for building fast, reliable web applications.
3. Developer Tooling Enhancements
The tooling improvements in .NET 9, including updates to Visual Studio, Visual Studio Code, and GitHub Copilot, significantly enhance developer productivity.
Visual Studio Updates
- Enhanced Debugging: The developer exception page now includes a routing tab, displaying endpoint metadata for better debugging and routing insights.
- Improved Data Visualization: A dictionary item debug view simplifies inspecting dictionary-based values like HTTP headers.
GitHub Copilot Enhancements
- Contextual Awareness: Copilot provides smarter code suggestions by analyzing project context.
- Semantic Code Generation: Ensures generated code aligns with project types and signatures.
-
Inline Chat for Modifications: With
Alt+/
, developers can refine Copilot's suggestions using natural language prompts. - Copilot Edits (Preview): This feature enables multi-file edits based on user prompts, generating a plan for review and acceptance. It streamlines complex code changes across the entire project.
These tooling updates reduce friction in development workflows, allowing developers to focus on building robust applications.
Why These Updates Matter
- Better API Design: Open API enhancements streamline API development, documentation, and testing.
- Higher Performance: Improvements in file delivery, memory management, and Blazor apps make .NET 9 a strong choice for high-performance web applications.
- Enhanced Productivity: Tooling updates provide smarter, faster workflows, empowering developers to build better solutions with ease.
Conclusion
.NET 9 brings a wealth of improvements to ASP.NET Core, addressing key pain points for modern web application development. With Open API updates, unmatched performance, and productivity-boosting tooling, .NET 9 solidifies ASP.NET Core as a premier framework for building scalable and high-performance web applications.
Are you excited about these enhancements? Share your thoughts and experiences in the comments below!
Posted on November 16, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 16, 2024