包阅导读总结
1.
关键词:ASP.NET Core 9、Static Web Optimization、Blazor Additions、New Project Template、Enhancements
2.
总结:.NET 9 Preview 5 为 ASP.NET Core 带来重大更新,包括静态网页资产交付优化、Blazor Server 重连体验改进、新特性及模板,还简化了认证状态序列化,引入新模板,详细信息可参考官方文档。
3.
主要内容:
– ASP.NET Core 9 Preview 5 发布
– 静态网页资产交付优化
– 新的 MapStaticAssets API 替代 UseStaticFiles,优化已知资产
– 压缩资产,减少大小,提高加载速度
– 设基于内容的 ETags,仅在内容改变时下载
– Blazor Server 改进
– 重连采用指数退避策略
– 自动刷新,更新重连 UI
– 新特性
– 运行时检测组件渲染模式
– 简化 Blazor Web Apps 认证状态序列化
– 新的.NET MAUI Blazor Hybrid 和 Web 解决方案模板
– 简化多平台应用创建,最大化代码复用
– 参考官方文档获取详细更新、变化及路线信息
思维导图:
文章来源:infoq.com
作者:Almir Vuk
发布时间:2024/6/26 0:00
语言:英文
总字数:556字
预计阅读时间:3分钟
评分:90分
标签:ASP.NET Core 9 预览版 5,开发,.NET 9,Blazor,.NET MAUI
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
Recently, Microsoft released .NET 9 Preview 5, introducing significant enhancements to ASP.NET Core. This update focuses on optimizing static web asset delivery and improving the Blazor Server reconnection experience, alongside new features for runtime detection of component render modes and various other improvements to simplify development and enhance user experience.
A major improvement in this release is the optimization of static web asset delivery. The new MapStaticAssets API is designed to replace UseStaticFiles in most cases. MapStaticAssets is optimized for assets known at build and publish time. It compresses assets using gzip and brotli, as stated, reducing their size and improving load times for users.
The API also sets up content-based ETags, ensuring that the browser only downloads files if their content changes. This change simplifies the process for developers, as new libraries or JS/CSS assets are automatically optimized and served faster, which is especially helpful for mobile users with limited bandwidth.
It is stated that even applications that use server-side compression can benefit from MapStaticAssets. With the explanation that the API allows for higher compression ratios because it takes more time during the build process, stating that using brotli compression can reduce the size of the MudBlazor CSS bundle from 90KB to 37KB.
The release also improves the Blazor Server reconnection experience. Blazor Server apps need a real-time connection to function. The new changes introduce an exponential backoff strategy for reconnection attempts, starting quickly and gradually introducing delays.
As stated, if a user returns to an app with a disconnected circuit, the app now tries to reconnect immediately. If the server has released the circuit, an automatic refresh is triggered, removing the need for manual intervention. Additionally, the reconnection UI has been updated to be more user-friendly.
Another new feature is detecting the component render mode at runtime. The ComponentBase class now includes a Platform property, soon to be renamed RendererInfo, with Name and IsInteractive properties. These properties help developers understand where their component runs and whether it is interactive. A new AssignedRenderMode property also provides information on how the component will render after prerendering.
Furthermore, this release has simplified authentication state serialization for Blazor Web Apps. New APIs make it easier to add authentication to existing projects. The development team states the following:
This works well if you’ve started from the Blazor web app project template and selected theIndividual Accountsoption, but it’s a lot of code to implement yourself or copy if you’re trying to add authentication to an existing project.
The new APIs, AddAuthenticationStateSerialization and AddAuthenticationStateDeserialization, simplify this process by adding necessary services to serialize and deserialize the authentication state, enhancing the app’s ability to access the authentication state during prerendering.
Additionally, a new .NET MAUI Blazor Hybrid and Web solution template has been introduced. As reported, this template simplifies creating apps that target Android, iOS, Mac, Windows, and Web while maximizing code reuse, and automatically sets up projects for a Blazor Web App and a .NET MAUI Blazor Hybrid app, using a shared Razor Class Library for UI components.
(Template from Visual Studio, Source: Official .NET GitHub)
Lastly, readers can refer to the official documentation for detailed reports on the latest updates. Readers can also review the breaking changes and the roadmap to understand the future direction and for a broader discussion detailed release notes onGitHub can be explored.