几个月前,在我升级到.net 5.0之前,这是可行的。
在Blazor页面上,我使用gRPC调用我的Ping("wee"),它应该返回一个字符串。相反,它给出了以下输出:
dbug: Grpc.Net.Client.Internal.GrpcCall[1]
Starting gRPC call. Method type: 'Unary', URI: 'https://localhost:44395/MyGrpc.GrpcWebService/Ping'.
dbug: Grpc.Net.Client.Internal.GrpcCall[18]
Sending message.
trce: Grpc.Net.Client.Internal.GrpcCall[21]
Serialized 'System.String' to 5 byte message.
trce: Grpc.Net.Client.Internal.GrpcCall[19]
Message sent.
trce: Grpc.Net.Client.Internal.GrpcCall[2]
Response headers received.
info: Grpc.Net.Client.Internal.GrpcCall[3]
Call failed with gRPC error status. Status code: 'Internal', Message: 'Bad gRPC response. HTTP status code: 400'.
dbug: Grpc.Net.Client.Internal.GrpcCall[4]
Finished gRPC call.如果我将url https://localhost:44395/MyGrpc.GrpcWebService/Ping粘贴到浏览器中,我得到的是Blazor页面,而不是gRPC编码的响应,我不确定从here...but到哪里去。
gRPC和Blazor路由之间是否存在冲突?
发布于 2020-11-28 06:43:00
好的,我会回答我自己的问题。事实证明,端点排序很重要。您必须注册您的gRPC服务
app.UseEndpoints(fun endpoints ->
endpoints.MapGrpcService<MyService>() |> ignore
endpoints.MapGrpcService<WeatherService>() |> ignore
endpoints.MapGrpcService<GrpcWebService>() |> ignore
)在标准blazor端点之前:
app.UseEndpoints(endpoints => {
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});https://stackoverflow.com/questions/65044281
复制相似问题