From 8eea584e2a0e818f1dd038654f2691e435727a8e Mon Sep 17 00:00:00 2001 From: Si Carter Date: Wed, 30 Aug 2023 18:30:23 +0200 Subject: [PATCH] Remove potential null exception (#275) --- .../Controllers/AccountController.Downloads.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/UserAccount.Plugin/Controllers/AccountController.Downloads.cs b/Plugins/UserAccount.Plugin/Controllers/AccountController.Downloads.cs index 0bd8bdacd..64388882c 100644 --- a/Plugins/UserAccount.Plugin/Controllers/AccountController.Downloads.cs +++ b/Plugins/UserAccount.Plugin/Controllers/AccountController.Downloads.cs @@ -101,7 +101,7 @@ public IActionResult DownloadView(int id) } [HttpPost] - public FileStreamResult DownloadFile(ViewDownloadViewItem model) + public IActionResult DownloadFile(ViewDownloadViewItem model) { if (model == null) throw new ArgumentNullException(nameof(model)); @@ -122,7 +122,10 @@ public FileStreamResult DownloadFile(ViewDownloadViewItem model) if (downloadItem != null) break; } - + + if (downloadItem == null) + return RedirectToAction(nameof(Index)); + string path = downloadItem.Filename; string name = Path.GetFileName(path); string ext = Path.GetExtension(path) ?? String.Empty;