Questions tagged [httpclienthandler]

22 questions
10
votes
1 answer

Access HttpClientHandler from HttpClient instance?

When working with a HttpClient instance and HttpClientHandler instance (.Net Framework, not using Core), is it possible to access the HttpClientHandler instance/its properties later in any way (for read-only purposes)? Unfortunately creating the…
cty
  • 357
  • 5
  • 16
7
votes
1 answer

Using SocketsHttpHandler in .NET Core 2.2 and ignoring cert validation

With HttpClientHandler, we are able to set a server validation callback and return true (by writing it out or using DangerousAcceptAnyServerCertificateValidator). How can I ensure that I bypass this verification also when I switch my HttpClient to…
djsoteric
  • 188
  • 1
  • 10
5
votes
0 answers

What are the Best Practices with using HttpClient & HttpClientHandler for multiple endpoints?

Using HttpClient is not as straight forward as I would've hoped. Despite it being an IDisposable type it is not best practice to wrap it in a using statement and it's even ideal to make it a singleton. However, what about when you pass in a…
Sam
  • 26,946
  • 12
  • 75
  • 101
4
votes
0 answers

How to pass HttpClientHandler to existing HttpClient?

I have HttpClient httpClient injected from outside of my class. Inside my class I'm creating a new HttpClientHandler var handler = new HttpClientHandler() and setting its values. I need to link HttpClientHandler to existing HttpClient the same way…
2
votes
0 answers

Detect "Is Client Certificate required" when using C# HttpClient

My client application calls an Azure App Service with HttpClient Something like this: HttpClientHandler handler = new HttpClientHandler(); if (I detect a certificate is needed) { httpClientHandler.ClientCertificates.Add(cert); …
user2081514
  • 95
  • 1
  • 7
1
vote
0 answers

HttpClient with HttpClientHandler ClientCertificate not working in c#

I need to send data to a webapi which needs a certificate to authorize. This is working on .net 4.5.2 with WebRequestHandler but when I try to upgrade to dotnet 5 and using HttpClientHandler I got an error: Message: The SSL connection could not be…
Shalom Dahan
  • 335
  • 7
  • 19
1
vote
0 answers

c# add CookieContainer to HttpClientHandler

I have the following function written in c#: public static string FunctionName() { try { using (var httpClient = new HttpClient()) { var uri = new Uri("https://www.website.com/api/1/auth/user"); …
pr0b
  • 377
  • 2
  • 3
  • 14
1
vote
0 answers

dotnet 5 how to use windows authentication credentials in HttpClient

issue in .net 5 that not happen in .net core 3.1 the windows authentication didn't pass to HttpClient this same code that work on .net core 3.1 : [HttpGet("getuser")] public async Task GetUser() { var handle = new HttpClientHandler …
1
vote
1 answer

await client.GetStringAsync(url) ERREUR

async void GetLieu(string place) { ShowProgressDialogue("Récupération des données..."); string MonURL = "https://hubeau.eaufrance.fr/api/v1/hydrometrie/referentiel/stations"; string url = MonURL +…
michael
  • 25
  • 7
1
vote
1 answer

Access IMemoryCache service from AddHttpClient

I am using .NET Core 3.1. On Startup, I am adding the following: public void ConfigureServices(IServiceCollection services) { services.AddHttpClient().ConfigurePrimaryHttpMessageHandler(() => { var handler = new…
PKCS12
  • 407
  • 15
  • 41
1
vote
1 answer

Using Network Creds in dotnet core app on a mac using HttpClient

Writing a dotnet core app. I need to log in with network credentials as the service (which happens to be a TFS on-prem server) uses those to authenticate. From my (and another team members') windows machine, the following code works:…
ejbaum
  • 73
  • 6
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 =…
0
votes
1 answer

Problem getting my application to log into webpage

The "*" are my credentials to log in, and are set to variables. When I run the code, my returned value is a string stating my conditional statement, else value. I am pretty sure I am thinking in the right direction, but somewhere in my thought…
0
votes
0 answers

.NET HttpClientHandler with ServerCertificateCustomValidationCallback , how to add additional information to generated AuthenticationException

I am using a custom server validation callback based on this example private void InitServices(IHostBuilder builder, ...) { ... builder .ConfigureServices((context, services) => { services.AddHttpClient("myHttpClient", c => …
RickyTad
  • 281
  • 1
  • 3
  • 15
0
votes
0 answers

VB.net FCM proxy 407 issue

I have a basic setup for Push Delivery, they are working fine without proxy. I tried to add a proxy setting but couldn't manage to make it work. I am using below function to deliver push notifications: Public Function Send(ByVal title As String,…
1
2