服务端

public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddAuthentication(CertificateAuthenticationDefaults.AuthenticationScheme)
            //.AddCertificate()
            //.AddCertificateCache();
            services.AddGrpc();
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseRouting();
            //下两行新增
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGrpcService<GreeterService>();

                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
                });
            });
        }
    }

客户端

 

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2019-11-20
  • 2022-12-23
  • 2022-12-23
  • 2020-02-15
  • 2022-02-12
  • 2021-06-26
猜你喜欢
  • 2022-12-23
  • 2022-01-21
  • 2021-12-17
  • 2021-08-05
  • 2018-06-29
  • 2021-09-08
  • 2021-07-02
相关资源
相似解决方案