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 8 Preview 1 Available

ASP.NET Core 8 Preview 1 Available

Last week Microsoft released the first look at the upcoming .NET version, featuring several ASP.NET Core-powered web development advancements. The .NET 8 version has a particular focus on enhancing ASP.NET Core features. Recent advancements will focus on areas like Blazor United, Authentication & Authorization experience, and Native AOT. With Blazor United, it will be possible to utilize a singular Blazor-based architecture that supports both server-side rendering and complete client-side interactivity via Blazor Server or WebAssembly.

As reported by Daniel Roth, principal program manager, ASP.NET

In .NET 8 we’re working to combine the benefits of server-side and client-side rendering into a single full-stack programming model based on Blazor. We’re currently calling this effort ;Blazor United;. Blazor United will enable you to use a single Blazor-based architecture for server-side rendering and full client-side interactivity with Blazor Server or WebAssembly. That’s all within a single project with the ability to easily switch between different rendering modes and even mix them in the same page. Blazor United will also enable new rendering capabilities, like streaming rendering and progressive enhancement of navigations and form posts.

Another area of focus is the complexity of authentication and authorization in specific cases for ASP.NET Core applications. This is something that the upcoming .NET 8 version will attempt to address. The upgrade promises to make it simple for developers to create and test web-based authentication and authorization by offering a hassle-free, logical, and well-documented experience. Additionally, it will provide a series of simple procedures and tools to assist with deploying apps to real-world settings and diagnostics to rapidly and efficiently address security problems.

In the previous major version of .NET, the console projects could be published as native AOT, which produced a platform-specific executable without the JIT runtime and allowed for faster startup and less memory use. Native AOT support for ASP.NET Core will be added with.NET 8, starting with cloud-focused API apps created with Minimum APIs that meet specific requirements for file size, startup time, working set, and performance throughput. More resources about this can be found on the official GitHub issue.

In addition to the changes already stated, ASP.NET Core will get many more improvements in the .NET 8. The ASP.NET Core roadmap for .NET 8, available on GitHub, comprehensively summarises these anticipated enhancements. One of the features of the new ASP.NETCore is the Route tooling. The new routing features introduced in .NET 8 are collectively known as "route tooling," which are built on Roslyn and automatically adapt to your IDE. Routing is the foundation of ASP.NET Core and is used to customize how HTTP requests are mapped to code in Minimal APIs, Web APIs, Razor Pages, and Blazor. To simplify this process, .NET 8 has introduced new features such as route syntax highlighting, autocomplete for parameter and route names, autocomplete for route constraints, and route analyzers and fixers. These improvements support Minimal APIs, Web APIs, and Blazor, making routing easier to learn and use for developers.

(Image source: Microsoft)

Another improvement is based on route constraints. In .NET 8, constraints have been optimized for improved performance. Regex constraints are now compiled, duplicates are shared between routes, and the alpha constraint uses a source-generated regex, all contributing to faster runtime performance.

Regarding analyzers for API development, to promote best practices, an analyzer in .NET 8 will issue a warning when the IHeaderDictionary.Add API is used and offers a code fixer that suggests switching to the indexer or Append API.
 

var context = new DefaultHttpContext();

context.Request.Headers.Add("Accept", "text/html"); // ASP0019 warning

context.Request.Headers["Accept"] = "text/html"; // Apply codefix using indexer

context.Request.Headers.Append("Accept", "text/html"); // Apply codefix using IHeaderDictionary.Append

In addition, Kestrel now allows the creation of an inter-process communication (IPC) server, which enables support for communication between Windows applications through the use of named pipes. Support for Application-Layer Protocol Negotiation (ALPN) has been added to macOS, allowing the use of TLS and HTTP/2 with ASP.NET Core. This feature is particularly useful for gRPC apps that require HTTP/2. HTTP/3 is a newer, faster Internet protocol that was standardized in June 2022, and it offers benefits like quicker connection setup, no head-of-line blocking, and better transitions between networks. ASP.NET Core and Kestrel had support for HTTP/3 in .NET 7, and in .NET 8, it will be enabled by default alongside HTTP/1.1 and HTTP/2.

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(serverOptions =>
{
    serverOptions.ListenNamedPipe("MyPipeName");
});

Other important updates for ASP.NET Core in .NET 8 Preview 1 include hot reload support, for instance, fields, properties, and events for .NET on WebAssembly, support for symbol servers when debugging .NET on WebAssembly, Blazor WebAssembly debugging in Firefox, the ability to dispatch exceptions to Blazor's SynchronizationContext, and experimental Webcil format for .NET assemblies. There is also a new option to keep the SPA development server running, and gRPC JSON transcoding no longer requires http.proto and annotations.proto. More details about this release and breaking changes can be found in the official documentation.

.NET 8 Preview 1 can be downloaded now. For Windows users, it is recommended to use the latest Visual Studio 2022 preview edition. Visual Studio for Mac support for .NET 8 is not currently available. 

About the Author

Rate this Article

Adoption
Style

BT