Grpc.Net.Client.Web 2.49.0

.NET 5.0 .NET Standard 2.0
NuGet\Install-Package Grpc.Net.Client.Web -Version 2.49.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Grpc.Net.Client.Web --version 2.49.0
<PackageReference Include="Grpc.Net.Client.Web" Version="2.49.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Grpc.Net.Client.Web --version 2.49.0
#r "nuget: Grpc.Net.Client.Web, 2.49.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Grpc.Net.Client.Web as a Cake Addin
#addin nuget:?package=Grpc.Net.Client.Web&version=2.49.0

// Install Grpc.Net.Client.Web as a Cake Tool
#tool nuget:?package=Grpc.Net.Client.Web&version=2.49.0

Grpc.Net.Client.Web

The .NET gRPC client can be configured to make gRPC-Web calls. This is useful for Blazor WebAssembly apps, which are hosted in the browser and have the same HTTP limitations of JavaScript code. Calling gRPC-Web with a .NET client is the same as HTTP/2 gRPC. The only modification is how the channel is created.

To use gRPC-Web:

  • Add a reference to the Grpc.Net.Client.Web package.
  • Ensure the reference to Grpc.Net.Client package is 2.29.0 or greater.
  • Configure the channel to use the GrpcWebHandler:
var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions
    {
        HttpHandler = new GrpcWebHandler(new HttpClientHandler())
    });

var client = new Greeter.GreeterClient(channel);
var response = await client.SayHelloAsync(new HelloRequest { Name = ".NET" });

The preceding code:

  • Configures a channel to use gRPC-Web.
  • Creates a client and makes a call using the channel.

GrpcWebHandler has the following configuration options:

  • InnerHandler: The underlying HttpMessageHandler that makes the gRPC HTTP request, for example, HttpClientHandler.
  • GrpcWebMode: An enumeration type that specifies whether the gRPC HTTP request Content-Type is application/grpc-web or application/grpc-web-text.
    • GrpcWebMode.GrpcWeb configures content to be sent without encoding. Default value.
    • GrpcWebMode.GrpcWebText configures content to be base64 encoded. Required for server streaming calls in browsers.
  • HttpVersion: HTTP protocol Version used to set HttpRequestMessage.Version on the underlying gRPC HTTP request. gRPC-Web doesn't require a specific version and doesn't override the default unless specified.

gRPC-Web and streaming

Traditional gRPC over HTTP/2 supports streaming in all directions. gRPC-Web offers limited support for streaming:

  • gRPC-Web browser clients don't support calling client streaming and bidirectional streaming methods.
  • gRPC-Web .NET clients don't support calling client streaming and bidirectional streaming methods over HTTP/1.1.
  • ASP.NET Core gRPC services hosted on Azure App Service and IIS don't support bidirectional streaming.

When using gRPC-Web, we only recommend the use of unary methods and server streaming methods.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (17)

Showing the top 5 NuGet packages that depend on Grpc.Net.Client.Web:

Package Downloads
M5x.Grpc

Package Description

CRZ

Package Description

SynapIot.Api.SDK

Package Description

Havit.Blazor.Grpc.Client The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

HAVIT Blazor stack - gRPC Support - client-side

Unihealth.DataLake.Api.Client

Package Description

GitHub repositories (7)

Showing the top 5 popular GitHub repositories that depend on Grpc.Net.Client.Web:

Repository Stars
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0, 6.0 and 7.0 projects you can use. Readme contains explanations on all projects.
grpc/grpc-dotnet
gRPC for .NET
microsoft/RockPaperScissorsLizardSpock
Rock, Paper, Scissors, Lizard, Spock - Sample Application
gustavnavar/Grid.Blazor
Grid component with CRUD for Blazor (client-side and server-side) and ASP.NET Core MVC
SteveSandersonMS/BlazeOrbital
Sample application for Blazor WebAssembly on .NET 6
Version Downloads Last updated
2.49.0 384 9/26/2022
2.49.0-pre1 211 9/1/2022
2.48.0 16,454 8/24/2022
2.48.0-pre1 217 8/17/2022
2.47.0 56,742 7/3/2022
2.47.0-pre1 621 6/23/2022
2.46.0 54,365 5/13/2022
2.46.0-pre1 852 4/28/2022
2.45.0 69,597 4/19/2022
2.45.0-pre1 246 4/7/2022
2.44.0 39,054 3/17/2022
2.44.0-pre1 1,030 3/9/2022
2.43.0 43,885 2/25/2022
2.43.0-pre1 5,169 1/28/2022
2.42.0 72,332 1/19/2022
2.42.0-pre1 2,293 12/30/2021
2.41.0 90,769 12/7/2021
2.41.0-pre1 24,231 11/12/2021
2.40.0 201,169 10/5/2021
2.40.0-pre1 489 9/9/2021
2.39.0 86,990 8/18/2021
2.39.0-pre1 17,593 8/6/2021
2.38.0 150,291 6/11/2021
2.38.0-pre1 407 6/4/2021
2.37.0 85,583 4/20/2021
2.37.0-pre1 259 4/14/2021
2.36.0 36,122 3/17/2021
2.36.0-pre1 564 3/9/2021
2.35.0 41,388 2/4/2021
2.35.0-pre1 211 1/26/2021
2.34.0 81,092 12/11/2020
2.34.0-pre1 340 12/1/2020
2.33.1 20,465 10/28/2020
2.33.1-pre1 314 10/22/2020
2.32.0 7,527 10/5/2020
2.32.0-pre1 846 9/8/2020
2.31.0 14,957 8/14/2020
2.31.0-pre2 301 8/3/2020
2.30.0 16,687 7/16/2020
2.30.0-pre1 889 6/17/2020
2.29.0 14,789 5/27/2020
2.29.0-pre1 750 5/15/2020
2.28.0-pre2 6,733 3/11/2020
2.28.0-pre1 8,440 3/3/2020
2.27.0-pre1 6,084 1/24/2020