5

I had Asp.net core and gRPC working on the browser...but now I get:

info: Grpc.AspNetCore.Server.ServerCallHandler[2]
  Request content-type of 'application/grpc-web' is not supported.

Any ideas on how to track this down?

Ray
  • 2,974
  • 20
  • 26
  • Have you done any changes to the project and then this started to happen or did all this just happen by it self all of the sudden? – Michel Jansson Dec 05 '20 at 20:56
  • I believe it's because of some changes I made. – Ray Dec 06 '20 at 15:35
  • Ok @Ray, I believe you have to give up some more info to have any chance of help.. – Michel Jansson Dec 07 '20 at 16:28
  • Wish I could've given more info that would have been useful. I was looking for more diagnostics that would point to the problem. Like listing supported content-types, etc... Anyway, I found the problem: I called app.UseEndpoints() twice is...bad? – Ray Dec 07 '20 at 19:03
  • BTW: I've added a unit test that catches this kinda error quicker. – Ray Dec 07 '20 at 19:07

2 Answers2

13

Likely an issue in your Startup.cs

Yours should look something like this enter image description here

My guess is that you are missing app.UseGrpcWeb() or the EnabledGrpc() on the EndpointConventionBuilder

thalacker
  • 2,389
  • 3
  • 23
  • 44
  • 1
    You saved my day! The only thing that I needed to change here are cors settings and to set it like here https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-6.0 – Vahid Feb 24 '22 at 23:59
7

I ran across this issue. I had my app.UseGrpcWeb(); before app.UseRouting();

It had to be after.

So correct order is:

    app.UseRouting();
    app.UseGrpcWeb();

See https://learn.microsoft.com/en-us/aspnet/core/grpc/browser?view=aspnetcore-5.0 -- "Configure gRPC-Web in ASP.NET Core"

RichardVNL
  • 197
  • 1
  • 7