gRPC support for ASP.NET Core
$ dotnet add package Grpc.AspNetCore.ServerGrpc.AspNetCore.Server is a gRPC server library for .NET.
In Startup.cs:
AddGrpc method.MapGrpcService method. For information about how to create gRPC services, see Create gRPC services and methods.public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>();
});
}
}
ASP.NET Core middleware and features share the routing pipeline, therefore an app can be configured to serve additional request handlers. The additional request handlers, such as MVC controllers, work in parallel with the configured gRPC services.