Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2021 09:20
What would you like to do?
gRPC request in .NET Core
// .NET Core 3.x
// To use gRPC without TLS following switch must be set before creating the GrpcChannel/HttpClient.
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var options = new GrpcChannelOptions();
var channel = GrpcChannel.ForAddress("https://localhost:5001", options);
var client = new FooService.FooServiceClient(channel);
// Asynchronous unary RPC
var foosRequest = new FooRequest { Message = "Sample request" };
var fooResponse = await client.GetFooAsync(foosRequest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment