dotnet-httpclient

Any way to differentiate Cancel and Timeout

眉间皱痕 提交于 2020-03-13 04:27:50
问题 I have some code that is validating some data by making calls to a number of other services. I start all of the calls in parallel and then wait until at least one of them finishes. If any of the requests fail, I don't care about the result of the other calls. I make the calls with HttpClient and I have passed an HttpMessageHandler in that does a bunch of logging. Essentially: protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken

Any way to differentiate Cancel and Timeout

血红的双手。 提交于 2020-03-13 04:27:44
问题 I have some code that is validating some data by making calls to a number of other services. I start all of the calls in parallel and then wait until at least one of them finishes. If any of the requests fail, I don't care about the result of the other calls. I make the calls with HttpClient and I have passed an HttpMessageHandler in that does a bunch of logging. Essentially: protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken

HttpClient.SendAsync throws ObjectDisposedException on Xamarin.Forms Android but not on UWP

◇◆丶佛笑我妖孽 提交于 2020-03-05 02:53:07
问题 I'm writing a Xamarin.Forms application and I'm trying to do a Post to my webserver with some JSON payload. This works fine in UWP, but on Android I get the following error: System.ObjectDisposedException: Can not access a closed Stream. at System.IO.StreamHelpers.ValidateCopyToArgs (System.IO.Stream source, System.IO.Stream destination, System.Int32 bufferSize) [0x0003a] in <19853c43ab794d18ab1a33ecb65b3c4d>:0 at System.IO.MemoryStream.CopyToAsync (System.IO.Stream destination, System.Int32

PutAsync doesn't send request to web api, but fiddler works fine

…衆ロ難τιáo~ 提交于 2020-03-02 04:40:06
问题 I have been trying to figure out what is going wrong for a few hours now and i just can't find what is going wrong. Via the Mvc application the put method doesn't get hit, the request doesn't happen. But when i test it in fiddler the PutMethod in the api works. Hopefully someone can clear things up for me. Also pointers for a better structure or some good documentation are welcome . public void UpdateWerknemerCompetentieDetail(int wnID, int WNC, CompetentieWerknemerDetail detail) { using

client.DeleteAsync - include object in body

可紊 提交于 2020-02-24 09:17:30
问题 I have an ASP.NET MVC 5 website - in C# client code I am using HttpClient.PutAsJsonAsync(path, myObject) fine to call a Json API (the API is also mine created in Web API). client.BaseAddress = new Uri("http://mydomain"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.PutAsJsonAsync("api/something", myObj); I would like to do the same with a Delete verb. However client

C# HttpClient not sending POST variables

拜拜、爱过 提交于 2020-02-08 04:51:07
问题 I'm trying to make an app that will send a POST request to https://owlexpress.kennesaw.edu/prodban/bwckschd.p_get_crse_unsec with some info and return a class list. You can go here to go through the search "I'm using Fall 2015, MATH, Course 1190". https://owlexpress.kennesaw.edu/prodban/bwckschd.p_disp_dyn_sched When I run the code below, it outputs what it returns to a string which goes into a webbrowser component. It shows: Class Schedule Search Fall Semester 2015 Mar 31, 2015 Stop You must

Attaching httpHandler to httpclientFactory webapi aspnetcore 2.1

拜拜、爱过 提交于 2020-02-02 12:14:46
问题 I am trying to attach an handler to httpclientfactory using "ConfigurePrimaryHttpMessageHandler" but when I look inside the HttpClient to see if the handler is there i cannot find it Am I attaching the handler correctly? Any Suggesions services.AddHttpClient<IGitHubClient,GitHubClient>(client => { client.BaseAddress = new Uri(myUri); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }) .ConfigurePrimaryHttpMessageHandler(() => new

Attaching httpHandler to httpclientFactory webapi aspnetcore 2.1

僤鯓⒐⒋嵵緔 提交于 2020-02-02 12:14:08
问题 I am trying to attach an handler to httpclientfactory using "ConfigurePrimaryHttpMessageHandler" but when I look inside the HttpClient to see if the handler is there i cannot find it Am I attaching the handler correctly? Any Suggesions services.AddHttpClient<IGitHubClient,GitHubClient>(client => { client.BaseAddress = new Uri(myUri); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }) .ConfigurePrimaryHttpMessageHandler(() => new

ASP.NET Web Api client to upload file. Pass object to post method

半城伤御伤魂 提交于 2020-01-25 10:38:28
问题 I am trying to upload file to DB server through Web API client VB class as below Public Class Uploads Public Property FileName As String Public Property uploadDateTime As DateTime Public Property File As Byte() End Class Then ASP.NET user upload the file using ASP.NET web form. After receieving this file we need to upload it to server through httpClient If FileUpload1.HasFile Then Dim newFile As New Uploads() newFile.FileName=FileUpload1.FileName newFile.uploadDateTime=DateTime.Now newFile

POST request changed to GET request when making a request from C# to WordPress

梦想的初衷 提交于 2020-01-25 10:13:35
问题 I have defined a route in WordPress using register_rest_route , this is set as a route that accepts only POST requests: register_rest_route( 'myNamespace', '/myRoute/', array( 'methods' => 'POST', 'callback' => 'myCallbackFunction', ) ); Making a POST request to this route using Postman returns the result I expect. However, making a request from a C# application using either System.Net.Http.HttpClient or System.Net.HttpWebRequest I receive a 404 response. When I change my register_rest_route