forked from VahidN/DNTCommon.Web.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDownloaderServiceController.cs
More file actions
33 lines (29 loc) · 992 Bytes
/
DownloaderServiceController.cs
File metadata and controls
33 lines (29 loc) · 992 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
31
32
33
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace DNTCommon.Web.Core.TestWebApp.Controllers
{
public class DownloaderServiceController : Controller
{
private readonly IDownloaderService _downloaderService;
public DownloaderServiceController(IDownloaderService downloaderService)
{
_downloaderService = downloaderService;
}
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> DownloadFile()
{
var url = Url.Action(nameof(Index), typeof(DownloaderServiceController).ControllerName(), null, Request.Scheme);
var result = await _downloaderService.DownloadPageAsync(url,
new AutoRetriesPolicy
{
MaxRequestAutoRetries = 2,
AutoRetriesDelay = TimeSpan.FromSeconds(3)
});
return Content(result.Data);
}
}
}