question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using an interceptor in Blazor WASM

See original GitHub issue

While trying to use the Logger sample interceptor in a Blazor WASM application, I got kind of stuck.

Currently, I am trying to do this:

builder.Services.AddScoped(services =>
            {
                var baseAddressMessageHandler = services.GetRequiredService<BaseAddressAuthorizationMessageHandler>();
                baseAddressMessageHandler.InnerHandler = new HttpClientHandler();
                var grpcWebHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb, baseAddressMessageHandler);

                var channel = GrpcChannel.ForAddress(builder.HostEnvironment.BaseAddress, new GrpcChannelOptions { HttpHandler = grpcWebHandler });

                var invoker = channel.Intercept(new ClientLoggerInterceptor());
                // ... what to do with invoker here?
                return channel;
            });

How should we return the channel back to DI with the logger ‘enabled’? Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mgravellcommented, Aug 29, 2020

@ChristianWeyer

GrpcClientFactory.CreateGrpcService<TService>(CallInvoker)

Not currently an extension method, but it can be with the simple addition of a this

0reactions
ChristianWeyercommented, Aug 29, 2020

Thanks, gentlemen - @JamesNK and @mgravell !

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I add HTTP interceptors in Blazor WASM?
You can use delegating handlers. Create a new class extending DelegatingHandler : public class MyDelegatingHandler : DelegatingHandler ...
Read more >
jsakamoto/Toolbelt.Blazor.HttpClientInterceptor
The class library that intercept all of the sending HTTP requests on a client side Blazor WebAssembly application. Supported Blazor versions. "Blazor ...
Read more >
Global HTTP Error Handling in Blazor WebAssembly
We can use the interceptor in the Blazor WebAssembly application to centralize the error handling logic. Without it, we would have to repeat ......
Read more >
How do I intercept routing in Blazor before it navigates?
In the following code, we use the NavigateTo() method to intercept routing inside the If condition. The routing happens according to the values...
Read more >
How-to Blazor articles!
I have an open-source project named TaskoMask on GitHub and I decided to rewrite one of its web projects that is named as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found