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.”
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
WriteAsJsonAsyncextension methods, which use the
System.Text.Jsonserializer 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
AllowAnonymousextension method when using endpoint routing.
- Custom handling of authorization failures: The team eased the custom handling of authorization failures by adding the new
IAuthorizationMiddlewareResultHandlerinterface, 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.”