Ejemplo n.º 1
0
        private async Task <T> GetAsync <T>(string uri, int maxRecord)
        {
            IDictionary <string, string> headerParam = new Dictionary <string, string>();

            headerParam.Add("API_KEY", _apiOptions.Value.ThirdPartyApiOptions.ApiKey);

            var client = _httpClientFactory.GetOrCreate(thirdPartyHost, headerParam);

            var completeUri     = string.Concat(uri, "?maxRecord=" + maxRecord);
            var responseMessage = await client.GetAsync(completeUri);

            return(DeserializeJson <T>(await responseMessage.Content.ReadAsStringAsync()));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DownloadFile()
        {
            var host            = new Uri("http://localhost:5000");
            var httpClient      = _httpClientFactory.GetOrCreate(host);
            var responseMessage = await httpClient.GetAsync("CommonHttpClientFactory/Index");

            var responseContent = await responseMessage.Content.ReadAsStringAsync();

            return(Content(responseContent));
        }