Files
Samuele Locatelli b86a6021bf Riorganizzazione alfabetica codice
- Adapter
- Decoder
- UI
2022-10-20 18:48:25 +02:00

46 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace MP.MONO.UI.Pages
{
/// <summary>
/// Gestione donwnload file csv
///
/// da valutare eventualmente xlsx con https://github.com/closedxml/closedxml
/// </summary>
public class DownloadModel : PageModel
{
#region Public Constructors
public DownloadModel(IWebHostEnvironment env)
{
_env = env;
}
#endregion Public Constructors
#region Public Methods
public IActionResult OnGet()
{
string fileName = "OUT.csv";
if (Request.Query.ContainsKey("fileName"))
{
fileName = Request.Query["fileName"];
}
var filePath = Path.Combine(_env.ContentRootPath, "temp\\", fileName);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
return File(fileBytes, "application/force-download", fileName);
}
#endregion Public Methods
#region Private Fields
private readonly IWebHostEnvironment _env;
#endregion Private Fields
}
}