问题描述
在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!