protected static IReadOnlyList<AbuseReportViewModel> GetReports()
Return Value
IReadOnlyList<System.ValueTuple<IWhois, AbuseReportMetaData, FileInfo>>.
protected static IReadOnlyList<AbuseReportViewModel> GetReports()
public class AbuseController : AbuseBaseController { const string cashKey = "__AbuseReports"; private readonly IMemoryCache _memory; List<AbuseReportViewModel> _data; public AbuseController(IMemoryCache memory,IFireWallConfig config ) { _memory = memory; if (!memory.TryGetValue<List<AbuseReportViewModel>>(cashKey, out var data)) { data = new List<AbuseReportViewModel>( base.GetReports()); memory.Set<List<AbuseReportViewModel>>(cashKey, data,config.Cashing.UserSession); } _data = data; } public IActionResult Index() { return View(_data); } public IActionResult Download(string id) { //pass a string using index isp and index report avoiding the need to show file paths to users of the site string[] values = id.Split('.'); if (values.Length == 2 && int.TryParse(values[0], out int isp) && isp>-1 && int.TryParse(values[1], out int report) && report>-1 && _data.Count > isp && _data[isp].Reports.Count > report && System.IO.File.Exists(_data[isp].Reports[report].Pdf) ) { return File(System.IO.File.ReadAllBytes(_data[isp].Reports[report].Pdf),"application/pdf",System.IO.Path.GetFileName(_data[isp].Reports[report].Pdf)); } return RedirectToAction(nameof(Index)); } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2