IIS上的ASP.NET Core grpc-Web返回404 [英] ASP.NET Core grpc-Web on IIS returns 404

查看:294
本文介绍了IIS上的ASP.NET Core grpc-Web返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在http://localhost:5000上调用ASP.NET Core gRPC-Web服务器的.NET Core gRPC-Web客户端可以正常工作.

.NET Core gRPC-Web client calling ASP.NET Core gRPC-Web server on http://localhost:5000 works fine.

使用虚拟应用程序(例如,"http://build.mycompany.ca/myapp")部署到IIS服务器的同一客户端代码调用服务器会导致

Same client code calling server deployed to an IIS server with a virtual application (e.g., "http://build.mycompany.ca/myapp") results in

Status(StatusCode =未实现",Detail =不良gRPC响应.HTTP状态代码:404")

Status(StatusCode="Unimplemented", Detail="Bad gRPC response. HTTP status code: 404")

我的ASP.NET Core 3.1服务器已正确设置.IE.,app.UseGrpcWeb(new GrpcWebOptions {DefaultEnabled = true});

My ASP.NET Core 3.1 server is set up correctly. i.e., app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true });

介于两者之间

app.UseRouting()

app.UseEndpoints(endpoints => {
    endpoints.MapControllers();
    endpoints
        .MapGrpcService<GrpcClientService>()
        .EnableGrpcWeb();
});

有什么主意我想念的是什么吗?

Any ideas what I'm missing here?

推荐答案

在Grpc客户端中仅使用URI的主机部分.需要DelegatingHandler重定向到目标主机上的子目录.

only the host portion of the URI is used in the Grpc client. A DelegatingHandler is required to redirect to a subdirectory on the target host.

https://github.com/grpc/grpc-dotnet/issues/880

这篇关于IIS上的ASP.NET Core grpc-Web返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆