News

Blazor Gets Authentication and Authorization in ASP.NET Core 3 Preview 6

Microsoft shipped ASP.NET Core 3.0 Preview 6, with the red-hot Blazor project getting built-in support for handling authentication and authorization, among other updates.

.NET Core 3.0 Preview 6 also shipped, as the company aims for a September GA release for the major update that's replacing the old Windows-only .NET Framework and ASP.NET Framework (Web development) with open source, cross-platform alternatives.

Blazor, a former experimental project that uses WebAssembly to let .NET coders create Web apps with C# instead of JavaScript, is now part of ASP.NET Core and has stirred huge interest in the Microsoft-centric developer camp.

In Preview 6, authentication and authorization functionality has been added to Blazor, along with a revamp of directive attributes, standardizing the syntax for the attributes used to direct component compilation, such as ref, bind, event handlers and more. "This makes the Razor syntax used by Blazor more consistent and predictable," said Daniel Roth, principal program manager for ASP.NET in a June 12 blog post. "It also paves the way for future extensibility."

Regarding the authentication and authorization functionality, he said, "The server-side Blazor template now supports options for enabling all of the standard authentication configurations using ASP.NET Core Identity, Azure AD, and Azure AD B2C. We haven't updated the Blazor WebAssembly templates to support these options yet, but we plan to do so after .NET Core 3.0 has shipped."

Preview 6 also includes several improvements to gRPC, the open source remote procedure call system created by Google. Many developers were up in arms about Microsoft's decision to not include the.NET Framework Windows Communication Foundation (WCF) functionality in .NET Core. Microsoft said, "If you are a remoting or WCF developer and want to build a new application on .NET Core, we would recommend either ASP.NET Core Web APIs or gRPC (Google RPC, which provides cross platform and cross programming language contract based RPCs)."

Since then, an open source Core WCF has been started to address the gap, but it needs much community support to become a finished product.

Meanwhile, Microsoft continues to improve gRPC functionality in ASP.NET Core, with the new Preview 6 sporting:

  • Managed gRPC Client: "In prior previews, we relied on the Grpc.Core library for client support. The addition of HTTP/2 support in HttpClient in this preview has allowed us to introduce a fully managed gRPC client." Note that commentary in the announcement post indicates this isn't supported yet in client-side Blazor.
  • gRPC Client Factory: "Building on the opinionated pattern we introduced in HttpClientFactory, we've added a gRPC client factory for creating gRPC client instances in your project."
  • gRPC Interceptors: "gRPC exposes a mechanism to intercept RPC invocations on both the client and the server. Interceptors can be used in conjunction with existing HTTP middleware. Unlike HTTP middleware, interceptors give you access to actual request/response objects before serialization (on the client) and after deserialization (on the server) and vice versa for the response."

Other updates include:

  • New Razor features:
    • The new @attribute directive adds the specified attribute to the generated class.
    • The new @code directive is used in .razor files (not supported in .cshtml files) to specify a code block to add to the generated class as additional members.
    • The new @key directive attribute is used in .razor files to specify a value (any object or unique identifier) that the Blazor diffing algorithm can use to preserve elements or components in a list.
    • The new @namespace specifies the namespace for the generated class or the namespace prefix when used in an _Imports.razor file.
  • Static assets in Razor class libraries: "Razor class libraries can now include static assets like JavaScript, CSS, and images. These static assets can then be included in ASP.NET Core apps by referencing the Razor class library project or via a package reference."
  • Projects now use System.Text.Json by default: "New ASP.NET Core projects will now use System.Text.Json for JSON handling by default. In this release we removed Json.NET (Newtonsoft.Json) from the project templates."
  • Certificate and Kerberos authentication
  • SignalR Auto-reconnect
.NET Core release notes provide more information, with the ASP.NET Core issues listed here.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube