forked from VahidN/DNTCommon.Web.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommonHttpClientFactoryController.cs
More file actions
30 lines (26 loc) · 954 Bytes
/
CommonHttpClientFactoryController.cs
File metadata and controls
30 lines (26 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace DNTCommon.Web.Core.TestWebApp.Controllers
{
public class CommonHttpClientFactoryController : Controller
{
private readonly ICommonHttpClientFactory _httpClientFactory;
public CommonHttpClientFactoryController(ICommonHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
public IActionResult Index()
{
return View();
}
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);
}
}
}