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 .NET 8 RC 2: Blazor, Identity, SignalR and More

ASP.NET Core .NET 8 RC 2: Blazor, Identity, SignalR and More

The latest release of .NET 8 Release Candidate 2 brings significant additions and changes to ASP.NET Core. This release is planned to be the last one before the final version of .NET 8 is released. The most notable enhancements for this release of ASP.NET Core are related to the Blazor alongside the updates regarding the Identity, API Authoring, SignalR, and new SPA templates for CLI.

The HTTP logging middleware now offers enhanced extensibility with several new features. These include HttpLoggingFields.Duration, which measures processing time in milliseconds and is added to the HttpLoggingFields.All set. Another addition is HttpLoggingOptions.CombineLogs, which consolidates all enabled logs into one entry at the end of a request/response, encompassing request, request body, response, response body, and duration.

Additionally, the introduction of IHttpLoggingInterceptor allows for customizing logged details by implementing and registering this service. Endpoint-specific log settings are applied first, with further customisation options for inspecting request/response data, enabling/disabling fields, adjusting body logging, and adding custom parameters to logs. As reported, multiple IHttpLoggingInterceptors can be registered and will execute in the order they are added.

Regarding the other Servers & middleware topic changes in RC 2, the ASP.NET Core now uses the latest version of the IdentityModel libraries, which contains the more performant JsonWebTokenHandler. These libraries enable enhanced performance and API consistency while ensuring full compatibility with Native Ahead-of-Time (AOT) compilation.

Changes regarding the API authoring include support for form files in new form binding, in RC2, the form binding implementation now supports binding types that contain an IFormFile property. Also, the SignalR support for stateful reconnect was previously introduced in .NET 8 previews. This feature has now been extended to the TypeScript client, improving its capabilities.

The Release Candidate 2 includes a lot of the changes and improvements regarding the Blazor, so the Blazor Web App template now offers global interactive render mode, making the entire app, including the router and layout, interactive. Furthermore, in .NET 8 RC2, changes have been made to the Blazor WebAssembly project templates. The Blazor WebAssembly App template is now named Blazor WebAssembly Standalone App since it no longer includes the ASP.NET Core hosted option.

For ASP.NET Core-hosted Blazor apps, the Blazor Web App template with the WebAssembly interactive render mode should be used. The Blazor WebAssembly App Empty template has been replaced with an option within the Blazor WebAssembly template for adding sample page content, and the template structure now aligns with the Blazor Web App template.

Other Blazor changes are related to File scoped @rendermode Razor directive, enhanced navigation & form handling improvements, orm model binding improvements, and from this release the developers can now access the current HttpContext as a cascading parameter from a static server component and there is a method to persist and read component state in a Blazor Web App using the existing PersistentComponentState service.

Blazor has introduced support for injecting keyed services using the [Inject] attribute. This enables the scoping of service registration and consumption when using dependency injection, providing more flexibility in managing services. Next, Blazor now supports the cancel and close events on the dialog HTML element alongside support for a custom error page for use with the ASP.NET Core exception handling middleware.

Furthermore, regarding the Identity in .NET 8 RC2, developers can now easily generate a full Blazor-based Identity UI by choosing the "Individual Accounts" authentication option. This can be done through Visual Studio's project dialog for Blazor Web Apps or via the command line with the following command:

dotnet new blazor -au Individual

Note that in Visual Studio, the Identity UI is scaffolded for a SQL Server database, while the command-line version uses SQLite by default and includes a pre-created SQLite database for identity management.

The initial blog post outlined specific known issues, with plans for resolution in the upcoming .NET 8 release. Additionally, the original announcement blog post contains an engaging comment section, encouraging interaction between the community and the .NET team. It is advisable for readers to delve into it for valuable additional insights about the RC 2 release.

About the Author

Rate this Article

Adoption
Style

BT