diff --git a/aspnetcore/grpc/configuration.md b/aspnetcore/grpc/configuration.md index 02d0126689..a0dd2714f9 100644 --- a/aspnetcore/grpc/configuration.md +++ b/aspnetcore/grpc/configuration.md @@ -69,6 +69,10 @@ The following code: [!code-csharp[](~/grpc/configuration/sample/Program.cs?name=snippet&highlight=3-8)] +Note that client interceptors aren't configured with `GrpcChannelOptions`. Instead, client interceptors are configured using the `Intercept` extension method with a channel. This extension method is in the `Grpc.Core.Interceptors` namespace. + +[!code-csharp[](~/grpc/configuration/sample/Program2.cs?name=snippet&highlight=4)] + [!INCLUDE[](~/includes/gRPCazure.md)] ## Additional resources diff --git a/aspnetcore/grpc/configuration/sample/Program2.cs b/aspnetcore/grpc/configuration/sample/Program2.cs new file mode 100644 index 0000000000..c2ade78582 --- /dev/null +++ b/aspnetcore/grpc/configuration/sample/Program2.cs @@ -0,0 +1,25 @@ +using System; +using System.Threading.Tasks; +using Greet; +using Grpc.Core; +using Grpc.Core.Interceptors; +using Grpc.Net.Client; + +namespace GrpcGreeterClient +{ + class Program + { + #region snippet + static async Task Main(string[] args) + { + var channel = GrpcChannel.ForAddress("https://localhost:5001"); + var callInvoker = channel.Intercept(new LoggingInterceptor()); + var client = new Greeter.GreeterClient(callInvoker); + + var reply = await client.SayHelloAsync( + new HelloRequest { Name = "GreeterClient" }); + Console.WriteLine("Greeting: " + reply.Message); + } + #endregion + } +}