Latest Top 10 .Net 9 Blazor Features
Shailendra Chauhan
Founder & CEO at ScholarHat | Microsoft MVP | Technical Consultant | Corporate Trainer | Author | Speaker
Blazor marked .NET 8 as a significant milestone. It gave us interactive render modes, static SSR for entire apps, and a lot more. Now, .NET 9 is on the horizon (November 2024), and while it may not be as glamorous, it certainly packs some big punches for developers.
.NET 9 brings a variety of new changes for ASP.NET Core Blazor developers, improving performance, interactivity, and developer experience. The new features described in .NET 9 Preview 7 add capabilities and optimizations to Blazor, making it even more adaptable for developing modern web and hybrid applications.
What's new about Blazor.Net 9? Let's break it down.
1..NET MAUI Blazor Hybrid and Web App Solution Template
Blazor now supports the creation of hybrid applications with .NET MAUI. A new solution template simplifies the creation of apps that integrate native.NET MAUI components with web-based Blazor components.
Interactive Render Mode: Developers can choose a render mode (e.g., server-side or WebAssembly) to customize the level of interaction for individual components.
Shared Razor Class Library: Razor components are shared between native and web components, encouraging code reuse.
2. Optimized Static Asset Delivery with MapStaticAssets Middleware
The new MapStaticAssets middleware enhances static asset delivery by:
3. Runtime Component State Querying (Better Server side connection)
Blazor now provides tools to better understand and optimize component states at runtime:
4. Enhanced Server-Side Reconnection
Blazor introduces better reconnection mechanisms for server-side applications:
Blazor.start({
circuit: {
reconnectionOptions: {
retryIntervalMilliseconds: (previousAttempts, maxRetries) =>
previousAttempts >= maxRetries ? null : previousAttempts * 1000
},
},
});
5. Simplified Authentication Serialization
Authentication APIs in ASP.NET Core now support:
6. Static Server-Side Rendering (SSR) with Interactive Routing
Blazor simplifies adding SSR pages alongside interactive components:
领英推荐
7. Constructor Injection for Razor Components
Razor components now allow constructor injection for services like NavigationManager. This enhancement allows developers to manage navigation and state updates directly in a component's constructor.
8. WebSocket Compression and Frame-Ancestors CSP
Blazor Interactive Server components now support:
9. Improved Input Handling with KeyboardEventArgs.IsComposing
The new KeyboardEventArgs.IsComposing property improves internationalization support by detecting composition sessions for keyboard input, which is crucial for handling complex character sets.
10. Virtualization Enhancements in QuickGrid
The QuickGrid component introduces an OverscanCount property, allowing developers to render additional rows outside the visible viewport, optimizing scrolling performance in virtualized grids.
<QuickGrid ItemsProvider="itemsProvider" Virtualize="true" OverscanCount="5">...</QuickGrid>
11. Range Input in InputNumberlt;TValuegt; Component
The InputNumber<TValue> component now supports type="range", enabling slider inputs for numerical values while maintaining model binding and form validation.
<EditForm> <InputNumber @bind-Value="Model.ProductCount" max="999" min="1" step="1" type="range" /> </EditForm>
A few more Blazor gifts for developers
Upgrade:
Moving Blazor projects from older.NET versions to .NET 9 should be a simple process. Here's the idea:
Conclusion
The updates in .NET 9 significantly enhance Blazor’s capabilities, offering developers better performance, simpler integration options, and tools for creating both interactive and static web applications. Whether you’re building hybrid apps with .NET MAUI, optimizing static assets, or integrating advanced features like server-side rendering and authentication, Blazor continues to deliver a robust framework for modern web development
Mentor | Trainer | Technical Content Writer | HTML | CSS | JavaScript | ReactJS | Java | Python | SQL Server | C | C++
2 个月Thanks for sharing!
Creative Graphic Designer & Digital Marketing Specialist | Skilled in Social Media & Performance Marketing | Seeking New Opportunities
2 个月Great advice
Working at ScholarHat || Bachelor of Science in Information Technology || UI/UX Designer
2 个月informative