dotnet-httpclient

Deadlock reading async response content from async DelegatingHandler in webapi

与世无争的帅哥 提交于 2019-12-06 10:18:28
Problem I'm using a DelegatingHandler in WebAPI to read the response Content and audit it to the database. When the code gets to .ReadAsStringAsync() it appears to lock and prevent other requests from completing. I only know this, because when I remove the offending line, it works perfectly. public static void Register(HttpConfiguration config) { config.MessageHandlers.Add(new ResourceAuditHandler()); } public class ResourceAuditHandler : DelegatingHandler { protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var

Can't Install System.Net.Http Package into a Windows Phone 7.1 Silverlight Project

十年热恋 提交于 2019-12-06 07:19:33
I used Nuget to install the "Microsoft ASP.NET Web API Client Libraries" to get the latest System.Net.Http assembly for use in Windows Phone 7.1 XNA and Silverlight projects. It installs just fine into my WP7.1 XNA projects, but doesn't allow me to install it into the WP7.1 Silverlight projects. I even tried installing it directly from the Package Manager Console into a newly created WP7.1 Silverlight project and got this Error response: PM> Install-Package System.Net.Http Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.0.20710.0 && < 2.1)'. You are downloading Microsoft.Net.Http

Delphi: TIdHTTP vs TNetHTTPClient

℡╲_俬逩灬. 提交于 2019-12-06 05:42:13
I'm writing a download manager in Delphi with some custom features like resumable downloads and downloading through proxies. I'm studing different component solutions: Indy and NetHTTP, both seem very close. TNetHTTPClient seem to be an interface of winhttp.dll . TIdHTTP seem to be an interface of wininet.dll (but i'm not sure). TIdHTTP seems like a very old component (maybe very stable/tested) and has tons of documentation online. TNetHTTPClient seems to be a very recent component, and doesn't have good documentation online. I'm a bit undecided... which one to choose? The point is: what is

How to Configure Network Tracing Dotnet core for HttpClient calls?

落爺英雄遲暮 提交于 2019-12-06 05:22:48
As per reference document at https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-configure-network-tracing We can setup this in web.config or any other configuration file and we get detailed system.net traces, packets traces for HttpClient calls and any kind of issue in HttpClient calls can be captured in traces, be it certificate, TLS or anything else. However, do we have similar implementation for dotnet core / standard which can be used in both web app or console app/ libraries ? Configuration for dotnet framwork : <configuration> <system.diagnostics> <sources>

What is the purpose of HttpClient.BaseAddress and why can't I change it after the first request

社会主义新天地 提交于 2019-12-06 05:04:49
So most of us have probably read that we are supposed to reuse instances of HttpClient instead of using using and creating new ones. That means I can just create a single instance of HttpClient in my program and call GetAsync using a full uri string per request. This leads me to the BaseAddress property of HttpClient . Consider the following code: HttpClient microsoftClient = new HttpClient() { BaseAddress = new Uri("https://www.microsoft.com/") }; HttpClient stackoverflowClient = new HttpClient() { BaseAddress = new Uri("https://stackoverflow.com/") }; var response = microsoftClient.GetAsync(

HttpClient - Xamarin Android - MvvmCross

此生再无相见时 提交于 2019-12-06 02:37:18
I've been developing an application for Android using Xamarin with MvvmCross and everything has been going fine, me and my team were able to develop the solution and this week we decided to make the final adjustments and to test the application in other environments. During the tests I had a huge problem with the Android solution. In the working environment everything was working fine but when I tried to test the application at home the application stopped working. I checked what was happening and I found out that the HttpClient was not being able to complete a call to the server and throwing

Properly Abort or Cancel PostAsync

蹲街弑〆低调 提交于 2019-12-06 01:49:46
问题 Is there a guaranteed way to cancel a post when using HttpClient? I currently have a call do PostAsync that I am attempting to cancel using a cancellationToken, but it appears that it does not actually abort/stop the operation. I still can see that the image I am uploading is posted properly. Am I doing something wrong here or is it possible that HttpClient is not processing the cancellation token until after the upload? var sc = new StreamContent(uploadFile.Data); content.Add(sc, uploadFile

Deadlock while blocking async HttpClient call within a task continuation

喜欢而已 提交于 2019-12-06 01:21:51
I am trying to wrap my head around synchronously calling async functions and deadlock. In the below example I am blocking an async call which internally uses ConfigureAwait(false) which as far as I can tell should prevent deadlock. The first call to the web service does not deadlock. However, the second one that happens within a continuation that syncs back to the UI thread deadlocks. GetBlocking_Click is a click event in a WPF app so both the first and the second request happen on the UI thread. private void GetBlocking_Click(object sender, RoutedEventArgs e) { const string uri = "http://www

Using HttpClient in a Xamarin core project

狂风中的少年 提交于 2019-12-05 22:41:40
问题 I am doing a project for multiple platforms where I have followed best practices and created a core project to contain all the code that is the same on all platforms. To do the network communication I would like to use HttpClient which seems to be the recommended approach for communicating with web services going forward. I am NOT doing a PCL but just a standard C# library to contain the core project. However it seems that there is no common implementation of HttpClient but only platform

Is my implementaton of HttpClient singleton appropriate? [closed]

丶灬走出姿态 提交于 2019-12-05 20:49:47
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I am using System.Net.HttpClient (.Net 4.5) in my MVC4 project. I know that a single instance of HttpClient can be used for all Http requests across the web app. Here is my implementation of the HttpClient singleton which should return the single instance every time. public