Questions tagged [delegatinghandler]

36 questions
1
vote
1 answer

How can I break the HTTP Interceptor circuit in Blazor WASM?

In my Blazor WebAseembly application there are a few HTTP interceptors (delegating handlers). The UnAuthorized interceptor checks the HTTP status code and if it's 401, the rest of the pipeline do not matter, and user needs to be redirected to the…
Parsa99
  • 307
  • 1
  • 13
1
vote
0 answers

Do I need a second HttpClient to make an API call to refresh JWT token inside custom DelegatingHandler?

For each API call in my App, I want to check whether the user has an expired JWT, and if so, I want to get a new one using a refresh token, and then proceed with the original request to API. This is supposed to all work in the background without the…
Varin
  • 2,354
  • 2
  • 20
  • 37
1
vote
1 answer

DelegatingHandler and HttpClient in a loop

I am trying to execute HttpClient.GetAsync in a loop. As per Microsoft Doc, it is recommended to use 1 instance of HttpClient. The way I'm getting HttpClient is var httpClient =…
1
vote
1 answer

Using DelegatingHandler to implement HTTP request retry logic

I'm trying to implement retry using DelegatingHandler but I also want to set HttpCompletionOption. My code looks like following : public class RetryHandler : DelegatingHandler { private readonly int MaxRetries; public…
vishwas-trivedi
  • 516
  • 2
  • 8
  • 26
1
vote
0 answers

"Cannot send the same request message multiple times" error from DelegatingHandler

I am not sure what is wrong in this code.Could someone please help me why i see error while running this code? Here is my handler code: public class TestHandler1 : DelegatingHandler { protected override async Task
Shags
  • 133
  • 1
  • 1
  • 7
1
vote
1 answer

Per Request Error Handling Policy

I'm attempting to follow this 2013 guide on setting up per-request error handling policies. If the request is local, display the error information. If the current user is in the IT group, display the error information. For everyone else, don't show…
user47589
1
vote
1 answer

SelfHost DelegatingHandler

i have created custom delegating handler and override it's method Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) now in that method i run custom synchronous method, can you guys let me know…
1
vote
1 answer

Wrapping WebApi responses using DelegatingHandler

I'm trying to use a DelegatingHandler to wrap my Web API responses. I'm using this as an example. At some point the content needs to be read from the response object: if (response.TryGetContentValue(out content) && ...) The solution didn't work…
Ropstah
  • 17,538
  • 24
  • 120
  • 194
1
vote
0 answers

global query parameter for webapi responses

I have a restful webapi, and I want to support a queryparameter for searching something like ?q= What I thought about doing is using delegatingHandler for changing the response Basically creating a QueryHandler for each type of…
VisualBean
  • 4,908
  • 2
  • 28
  • 57
1
vote
1 answer

Does DelegatingHandler has any performance side effects?

I have this delegating handler in my api project: class MyHandler : DelegatingHandler { protected override async Task SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { var…
amiry jd
  • 27,021
  • 30
  • 116
  • 215
1
vote
1 answer

DelegatingHandler works on Localhost but not on Azure

I have the following code which works fine when forwarding to my localhost:1671: protected override async System.Threading.Tasks.Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { …
0
votes
0 answers

Share code between Middleware and DelegatingHandler

dotnet version: 6.0.300 I am currently writing a custom monitorization feature, that observes requests to all controllers, as well as outbound requests to other apis. Currently, I have integrated two separate solutions - that practically do the same…
0
votes
0 answers

How to use DelegatingHandler in .net core for remove property from Response in asp.net core?

How to use DelegatingHandler in .net core for remove property from Response in asp.net core? if logged-in user is not Admin then how to remove some property from response in API?
anisa
  • 1
  • 2
0
votes
0 answers

how can i configure a message handler based on the environment in webapiconfig.cs file?

I am using Aspnet webapi2. I want to register a message handler based on the environment. can you please let me know how can i configure the same based on environment. public static class WebApiConfig { public static void…
0
votes
1 answer

When and why should we use WebApi Action Filter and DelegationHandler?

I am on a project that needs to have a cross-cutting error handling and response manipulation. I found there are Filters And Delegating Handlers, but I don't know the difference between these two, can someone help me please to figure this out?
Nasir Jafarzadeh
  • 6,123
  • 1
  • 13
  • 19