system.net.httpwebrequest

Xamarin Forms, HttpClient class - GetStringAsync and GetAsync return null value and exit from function quickly

…衆ロ難τιáo~ 提交于 2020-03-05 04:13:50
问题 when I run my code, in my function that call GetStringAsync or GetAsync, this 2 calls returns null value and immediately exit from my function (all code after is unreached ) I make a web api that is is reachable from web browser (url reached on browser) , also in the emulator browser ( Browser on the Android Emulator ) then i try to make a xamarin forms that manages to communicate with it class MainPageViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler

Passing body content when calling a Delete Web API method using System.Net.Http

别说谁变了你拦得住时间么 提交于 2020-02-03 04:34:05
问题 I have a scenario where I need to call my Web API Delete method constructed like the following: // DELETE: api/products/{id}/headers [HttpDelete("{id}/headers")] public void DeleteProductHeaders(int id, [FromBody] string query) { } The trick is that in order to get the query over I need to send it through the body and DeleteAsync does not have a param for json like post does. Does anyone know how I can do this using System.Net.Http client in c#? // Delete a product's headers public void

HttpWebRequest in .NET Core 2.0 throwing 302 Found Exception

醉酒当歌 提交于 2020-01-14 07:28:18
问题 We are upgrading our application from .net framework to .net core 2.0. In it, we use a HttpWebRequest to contact a site with AllowAutoRedirect set to false. When the code executed request.GetResponse() The site will return a 302 response, which in .net framework is OK - you can take response and handle it (we are after the set-cookie header value). However, in .net core 2.0, a WebException gets thrown: The remote server returned an error: (302) Found. Is my understanding incorrect in that a

Xamarin Forms - Cannot set the ContentLenght of HttpWebRequest

强颜欢笑 提交于 2020-01-05 07:22:29
问题 I tried to mke a request with GET and parameters. However, I got an exception for the WinPhone8.1 which meaned that GET was a violation protocol due to a content added in. So making a POST request is the solution. Despite my searches, I'm still not able to set the content lenght property of my HttpWebRequest.. Why? private static async void AsyncRequest(string url, string contentType, string methodType, int contentLenght, Action<Object, string> callback, Action<HttpStatusCode, JObject, Action

Xamarin Forms - Cannot set the ContentLenght of HttpWebRequest

别等时光非礼了梦想. 提交于 2020-01-05 07:21:09
问题 I tried to mke a request with GET and parameters. However, I got an exception for the WinPhone8.1 which meaned that GET was a violation protocol due to a content added in. So making a POST request is the solution. Despite my searches, I'm still not able to set the content lenght property of my HttpWebRequest.. Why? private static async void AsyncRequest(string url, string contentType, string methodType, int contentLenght, Action<Object, string> callback, Action<HttpStatusCode, JObject, Action

What's the alternative to WebRequestHandler in .NET Core?

▼魔方 西西 提交于 2020-01-03 08:58:48
问题 I was using the WebRequestHandler for setting the CachePolicy and AuthenticationLevel in my full stack .NET application. Now I am migrating my application to .NET core and can't find an alternative to these properties or the WebRequestHandler. Any help? Following is my usage: var httpClientHandler = new WebRequestHandler { UseProxy = true, UseCookies = false, CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore), AuthenticationLevel = AuthenticationLevel

Why is System.Net.Http HttpClient encoding my request URL?

强颜欢笑 提交于 2019-12-24 20:43:23
问题 I use the HttpClient in System.Net.Http to make requests to a web service as below: using (var client = new HttpClient()) { using (var response = client.GetAsync(url).Result) { var result = response.Content.ReadAsStringAsync().Result; } } I have a sandbox application and a live application. The sandbox application has identical code (in a shared repository) which works fine, but when client.GetAsync(url).Result is called in the live application, for some reason Fiddler shows me that the

Using GoogleApisClient ServiceAccountCredential calling RequestAccessTokenAsync throws Exception

与世无争的帅哥 提交于 2019-12-23 09:38:25
问题 Background: I have set up a Service Account for my project on Google Developer Console and using the Service Account Email, the Certificate and the secret password and following the example provide in the GoogleAPisSample Plus.ServiceAccount. The snippet below is part of my Windows Service application: var List<string> Scopes = new List<string> { "https://www.googleapis.com/auth/analytics.readonly" }; var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer

Web Api: System.Net.Http version 2.0.0.0 not found

纵饮孤独 提交于 2019-12-07 03:36:05
问题 When I install the NuGet package for WebApi, it gives me version 1.0.0.0 of System.Net.Http, yet it references version 2. I cannot seem to find version 2 for the life of me. When I download .net 4.5 I get System.Net.Http version 4.0.315.x, but I cannot use that because the Web Api assemblies refer to version 2.0.0.0. Anyone know where I can find this version 2.0.0.0? I've tried the NuGet package manager, mvc4, .net 4.5, and nothing is giving me version 2. Thanks in advance. 回答1: Add the below

The request was aborted: The request was canceled. No solution works

余生颓废 提交于 2019-12-05 22:59:38
问题 Our console applications are making hundreds of WebRequests to Facebook every minute (with using multiple apps and hundreds of access tokens). Now, they started to fail with the exception message in the title ("The request was aborted: The request was canceled"). We searched for hours on the internet, and tried out every possible solution, but nothing helped. These didn't help: webRequest.Timeout = 20000; //A request that didn't get respond within 20 seconds is unacceptable, and we would