Skip to content

Commit e113f2a

Browse files
authored
Add Envoy comparison (#17816)
1 parent 49b6dde commit e113f2a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

aspnetcore/grpc/browser.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: jamesnk
44
description: Learn how to configure gRPC services on ASP.NET Core to be callable from browser apps using gRPC-Web.
55
monikerRange: '>= aspnetcore-3.0'
66
ms.author: jamesnk
7-
ms.date: 02/16/2020
7+
ms.date: 04/15/2020
88
uid: grpc/browser
99
---
1010
# Use gRPC in browser apps
@@ -23,6 +23,15 @@ By [James Newton-King](https://twitter.com/jamesnk)
2323
2424
It is not possible to call a HTTP/2 gRPC service from a browser-based app. [gRPC-Web](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md) is a protocol that allows browser JavaScript and Blazor apps to call gRPC services. This article explains how to use gRPC-Web in .NET Core.
2525

26+
## gRPC-Web in ASP.NET Core vs. Envoy
27+
28+
There are two choices for how to add gRPC-Web to an ASP.NET Core app:
29+
30+
* Support gRPC-Web alongside gRPC HTTP/2 in ASP.NET Core. This option uses middleware provided by the `Grpc.AspNetCore.Web` package.
31+
* Use the [Envoy proxy's](https://www.envoyproxy.io/) gRPC-Web support to translate gRPC-Web to gRPC HTTP/2. The translated call is then forwarded onto the ASP.NET Core app.
32+
33+
There are pros and cons to each approach. If you're already using Envoy as a proxy in your app's environment, it might make sense to also use it to provide gRPC-Web support. If you want a simple solution for gRPC-Web that only requires ASP.NET Core, `Grpc.AspNetCore.Web` is a good choice.
34+
2635
## Configure gRPC-Web in ASP.NET Core
2736

2837
gRPC services hosted in ASP.NET Core can be configured to support gRPC-Web alongside HTTP/2 gRPC. gRPC-Web does not require any changes to services. The only modification is startup configuration.
@@ -94,7 +103,7 @@ The preceding code:
94103
The `GrpcWebHandler` has the following configuration options when created:
95104

96105
* **InnerHandler**: The underlying <xref:System.Net.Http.HttpMessageHandler> that makes the gRPC HTTP request, for example, `HttpClientHandler`.
97-
* **Mode**: An enumeration type that specifies whether the gRPC HTTP request request `Content-Type` is `application/grpc-web` or `application/grpc-web-text`.
106+
* **Mode**: An enumeration type that specifies whether the gRPC HTTP request `Content-Type` is `application/grpc-web` or `application/grpc-web-text`.
98107
* `GrpcWebMode.GrpcWeb` configures content to be sent without encoding. Default value.
99108
* `GrpcWebMode.GrpcWebText` configures content to be base64 encoded. Required for server streaming calls in browsers.
100109
* **HttpVersion**: HTTP protocol `Version` used to set [HttpRequestMessage.Version](xref:System.Net.Http.HttpRequestMessage.Version) on the underlying gRPC HTTP request. gRPC-Web doesn't require a specific version and doesn't override the default unless specified.

0 commit comments

Comments
 (0)