Using an interceptor in Blazor WASM
See original GitHub issueWhile 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:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ChristianWeyer
Not currently an extension method, but it can be with the simple addition of a
this
Thanks, gentlemen - @JamesNK and @mgravell !