In .NET 8, ASP.NET Core provides a comprehensive solution for contemporary web development. It takes care of all your front-end and back-end web development requirements. Blazor offers dependable, high-performance backend APIs and services that let you create stunning, richly interactive web experiences. Cloud-native application development is made easy with ASP.NET Core in .NET 8, and productivity is enhanced by excellent tools in Visual Studio and Visual Studio Code. Every developer is a full stack developer with ASP.NET Core in .NET 8!

Let’s examine some of the fantastic enhancements and new features that ASP.NET Core in .NET 8 has to offer.

Advantages of Using Native AOT With ASP.NET Core

Publishing and deploying a native AOT program can bring the following advantages:

  • Reduced disk footprint: When publishing with native AOT, a single executable is created that includes the program as well as a subset of code from external dependencies that the program utilizes. Reduced executable size may lead to:
    • Smaller container images, such as those used in containerized deployments.
    • Smaller pictures lead to a faster deployment time.
  • Reduced startup time: The absence of JIT compilation allows native AOT programs to start up faster.
    • Reduced start-up time means the program can handle requests more quickly.
    • Improved deployment by using container orchestrators to control app version transitions.
  • Reduced memory demand: Because ASP.NET Core apps are published as native AOT, they can have lower memory demands depending on the work being done, as the new DATAS GC mode is automatically enabled. Reduced memory consumption can result in higher deployment density and better scalability.

AOT compatibility for both ASP.NET Core and native

Not every functionality in ASP.NET Core is compatible with native AOT. Similarly, not all libraries used in ASP.NET Core are compatible with native AOT. .NET 8 marks the beginning of efforts to enable native AOT in ASP.NET Core, with an emphasis on enabling support for apps that use Minimal APIs or gRPC and are deployed in cloud settings.

Native AOT apps have a few core compatibility requirements. The main ones include:

  • No dynamic loading (such as Assembly.LoadFile).
  • No runtime code generation by JIT (for example, System.Reflection.Emit)
  • No C++/CLI
  • No built-in COM (only applicable to Windows).
  • Requires trimming, which has restrictions.
  • Implies compilation into a single file with known incompatibilities.
  • Apps include required runtime libraries (like self-contained apps, increasing their size as compared to framework-dependent apps).

AOT with minimal APIs and native capabilities

Developers introduced the Request Delegate Generator (RDG) to ensure that Minimal APIs are compatible with native AOT. The RDG is a source generator that does similar work to the RequestDelegateFactory (RDF), converting the various MapGet(), MapPost(), and so on calls in your application into RequestDelegates associated with the specified routes, but it does so at compile time and generates C# code directly into your project. This removes the runtime creation of this code and ensures that the types used in your APIs are retained in your application code in a fashion that the native AOT tool-chain can statically analyze, guaranteeing that required code is not clipped. They’ve worked to guarantee that the RDG supports the majority of the Minimal API features you use today, making them compatible with native AOT.

.NET WebAssembly enhancements

Running .NET code on WebAssembly from the browser has been considerably enhanced in .NET 8. Your .NET code will run significantly quicker thanks to the new Jiterpreter-based runtime, which supports partial just-in-time (JIT) compilation for WebAssembly. With the new runtime, components render 20% quicker, and JSON deserialization is twice as quick!

The .NET WebAssembly runtime also supports numerous new edit types with Hot Reload, including full compatibility with CoreCLR’s Hot Reload capabilities and generic type editing. WebCIL, a new web-friendly packaging format for Blazor WebAssembly programs, simplifies deployment by eliminating all Windows-specific parts from.NET assemblies and repackaging them as WebAssembly files. WebCIL allows you to deploy your Blazor WebAssembly programs with certainty.

JavaScript SDK and project framework

Working with ASP.NET Core frequently necessitates the use of JavaScript and the JavaScript ecosystem. Bridging the .NET and JavaScript worlds can be difficult. The new JavaScript SDK and project system in Visual Studio make it simple to integrate .NET with frontend JavaScript frameworks. The JavaScript SDK integrates MSBuild, allowing you to build, run, debug, test, and publish JavaScript or TypeScript code alongside your .NET applications. You may easily interact with common JavaScript build tools such as WebPack, Rollup, Parcel, esbuild, and others.

You can quickly get started using ASP.NET Core with Angular, React, and Vue using the provide Visual Studio templates.

These templates are available for both JavaScript and TypeScript, and the client app is generated using the most recent frontend JavaScript CLI tooling, ensuring that you always have the most recent version.

Debugging improvements

.NET’s sophisticated debugger is essential for developing any .NET app, including ASP.NET. In .NET 8, developers have improved the debugging visualization experience for commonly used types in ASP.NET Core apps, ensuring that the debugger displays the most critical information right immediately.

Check out all of the new ASP.NET debugging features in this Debugging Enhancements in .NET 8 blog post.

Wrapping Up

In conclusion, the advancements and new features introduced in ASP.NET Core in .NET 8 represent a significant leap forward in the realm of web development. The integration of Blazor provides a comprehensive solution for both front-end and back-end development, empowering developers to create stunning and highly interactive web experiences. .NET 8 is currently available. Upgrade your ASP.NET Core projects now!