News

Blazor WebAssembly Template Lands in .NET 5 Preview 6

Microsoft shipped Preview 6 of the unifying .NET 5 framework, with several updates being added to the web site development component of the framework -- ASP.NET Core -- including the addition of a Blazor WebAssembly template.

.NET 5 is designed to combine everything .NET so "there will be just one .NET going forward, and you will be able to use it to target Windows, Linux, macOS, iOS, Android, tvOS, watchOS and WebAssembly and more."

In that new scheme, one hot topic in the .NET developer community is Blazor, because it allows coding browser/web apps with C# instead of JavaScript, which is used almost universally in the rest of the webdev ecosystem. Blazor WebAssembly is the client-side part of that effort.

Due to tricky problems encountered with using WebAssembly in .NET browser apps, Blazor WebAssembly trailed its server-side component -- Blazor Server -- by many months, finally being announced as being complete just last month.

"Blazor WebAssembly is now the second supported way to host your Blazor components: client-side in the browser using a WebAssembly-based .NET runtime," Microsoft said last month. "Blazor WebAssembly includes a proper .NET runtime implemented in WebAssembly, a standardized bytecode for the web. This .NET runtime is downloaded with your Blazor WebAssembly app and enables running normal .NET code directly in the browser."

In a June 26 blog post announcing ASP.NET Core updates in the new .NET 5 Preview 6, Microsoft's Sourabh Shirhatti highlighted the addition of the Blazor WebAssembly template.

"The Blazor WebAssembly template is now included in the .NET 5 SDK along with the Blazor Server template," Shirhatti said. "To create a Blazor WebAssembly project, simply run dotnet new blazorwasm."

Other relatively minor ASP.NET Core highlights of the release -- .NET 5 is only 2 previews away from being deemed feature complete -- include:

  • JSON extension methods for HttpRequest and HttpResponse: Developers can now easily read and write JSON data from HttpRequest and HttpResponse using the new ReadFromJsonAsync and WriteAsJsonAsync extension methods, which use the System.Text.Json serializer to handle the JSON data.
  • Extension method to allow anonymous access to an endpoint: Developers now have the ability to allow anonymous access to an endpoint using the simpler AllowAnonymous extension method when using endpoint routing.
  • Custom handling of authorization failures: The team eased the custom handling of authorization failures by adding the new IAuthorizationMiddlewareResultHandler interface, invoked by the AuthorizationMiddleware. "The default implementation remains the same, but a custom handler can be be registered in DI which allows things like custom HTTP responses based on why authorization failed."
  • SignalR Hub filters: SignalR allows server code to send asynchronous notifications to client-side web applications. ASP.NET lets developers' server-side code push content in real-time to connected clients with the help of client SDKs for JavaScript, .NET (C#, F#, and VB), and Java. In the new update, Hub filters -- called Hub pipelines in ASP.NET SignalR -- allows developers to run code before and after Hub methods are called, similar to how middleware allows running code before and after an HTTP request. This is useful for things like logging, error handling, and argument validation.

More information is available in the .NET 5 Preview 6 release notes, along with a list of breaking changes.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Poisson Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demo of Poisson regression, where the goal is to predict a count of things arriving, such as the number of telephone calls received in a 10-minute interval at a call center. When your source data is close to mathematically Poisson distributed, Poisson regression is simple and effective.

  • Cloud-Focused .NET Aspire 9.1 Released

    Along with .NET 10 Preview 1, Microsoft released.NET Aspire 9.1, the latest update to its opinionated, cloud-ready stack for building resilient, observable, and configurable cloud-native applications with .NET.

  • Microsoft Ships First .NET 10 Preview

    Microsoft shipped .NET 10 Preview 1, introducing a raft of improvements and fixes across performance, libraries, and the developer experience.

  • C# Dev Kit Previews .NET Aspire Orchestration

    Microsoft's dev team has been busy updating the C# Dev Kit, a Visual Studio Code extension that enhances the C# development experience by providing tools for managing, debugging, and editing C# projects.

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

Subscribe on YouTube

Upcoming Training Events