Dogodek
Power BI DataViz Svetovno prvenstvo
14. feb., 16h - 31. mar., 16h
S 4 možnosti za vstop, bi lahko zmagal konferenčni paket in da bi bilo v ŽIVO Grand Finale v Las Vegasu
Več informacijTa brskalnik ni več podprt.
Izvedite nadgradnjo na Microsoft Edge, če želite izkoristiti vse prednosti najnovejših funkcij, varnostnih posodobitev in tehnične podpore.
Opomba
This isn't the latest version of this article. For the current release, see the .NET 9 version of this article.
Opozorilo
This version of ASP.NET Core is no longer supported. For more information, see the .NET and .NET Core Support Policy. For the current release, see the .NET 9 version of this article.
Pomembno
This information relates to a pre-release product that may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
For the current release, see the .NET 9 version of this article.
This article discusses how to use the .NET gRPC client with .NET implementations that support .NET Standard 2.0.
The following .NET implementations (or later) support Grpc.Net.Client but don't have full support for HTTP/2:
The .NET gRPC client can call services from these .NET implementations with some additional configuration.
An HTTP provider must be configured using GrpcChannelOptions.HttpHandler
. If a handler isn't configured, an error is thrown:
System.PlatformNotSupportedException
: gRPC requires extra configuration to successfully make RPC calls on .NET implementations that don't have support for gRPC over HTTP/2. An HTTP provider must be specified usingGrpcChannelOptions.HttpHandler
. The configured HTTP provider must either support HTTP/2 or be configured to use gRPC-Web.
.NET implementations that don't support HTTP/2, such as UWP and Unity, can use gRPC-Web as an alternative.
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" });
Clients can also be created using the gRPC client factory. An HTTP provider is configured using the ConfigurePrimaryHttpMessageHandler extension method.
builder.Services
.AddGrpcClient<Greet.GreeterClient>(options =>
{
options.Address = new Uri("https://localhost:5001");
})
.ConfigurePrimaryHttpMessageHandler(
() => new GrpcWebHandler(new HttpClientHandler()));
For more information, see Configure gRPC-Web with the .NET gRPC client.
Pomembno
gRPC-Web requires the client and server to support it. gRPC-Web can be quickly configured by an ASP.NET Core gRPC server. Other gRPC server implementations require a proxy to support gRPC-Web.
.NET Framework has limited support for gRPC over HTTP/2. To enable gRPC over HTTP/2 on .NET Framework, configure the channel to use WinHttpHandler.
Requirements and restrictions to using WinHttpHandler
:
System.Net.Http.WinHttpHandler
version 6.0.1 or later.WinHttpHandler
on the channel using GrpcChannelOptions.HttpHandler
.var channel = GrpcChannel.ForAddress("https://localhost:5001", new GrpcChannelOptions
{
HttpHandler = new WinHttpHandler()
});
var client = new Greeter.GreeterClient(channel);
var response = await client.SayHelloAsync(new HelloRequest { Name = ".NET" });
An alternative option for .NET Framework has been to use gRPC C# core-library to make gRPC calls. gRPC C# core-library is:
Povratne informacije o izdelku ASP.NET Core
ASP.NET Core je odprtokodni projekt. Izberite povezavo za pošiljanje povratnih informacij:
Dogodek
Power BI DataViz Svetovno prvenstvo
14. feb., 16h - 31. mar., 16h
S 4 možnosti za vstop, bi lahko zmagal konferenčni paket in da bi bilo v ŽIVO Grand Finale v Las Vegasu
Več informacijUsposabljanje
Modul
Implement HTTP operations in ASP.NET Core Blazor Web apps - Training
Implement HTTP operations in ASP.NET Core Blazor Web apps