Software

Experimental gRPC web Support for .NET

Earlier this week, Microsoft announced experimental support for gRPC-Web with .NET Core. The new addition allows Blazor WebAssembly clients to call gRPC applications directly from the browser, enabling gRPC features such as server streaming to be used by browser-based applications.

Originally developed and used by Google, gRPC is a remote procedure call system officially recommended by Microsoft as a replacement to WCF in .NET Core. Although the .NET support is still experimental, gRPC-Web is not a new technology: released in 2018 as a JavaScript client library, it allows web applications to communicate directly with gRPC services without using an HTTP server as a proxy.

Similarly to gRPC, gRPC-Web uses pre-defined contracts between the (web) client and backend gRPC services. It allows the creation of an end-to-end gRPC pipeline compatible with HTTP/1.1 and HTTP/2 - which is particularly relevant since browser APIs can't call gRPC HTTP/2.

The new experimental features allow ASP.NET Core gRPC applications to be called from the browser by both .NET Blazor WebAssembly applications and JavaScript SPAs. They also offer an alternative to hosting ASP.NET Core gRPC applications in IIS and Azure App Service, since neither server can currently host gRPC services. The new features include support for server streaming, using Protobuf messages, and strongly-typed coded-generated clients.

It is also important to notice that not all gRPC features are supported (i.e., client streaming and bi-directional streaming). Using gRPC-Web for .NET requires .NET Core 3.1.