public IActionResult ExportUser() { try { // 調用 CSVService 提供的函數來匯出用戶資料 CSVService.ExportUser(_context); return(RedirectToRoute(new { controller = "User", action = "Index" })); } catch (Exception ex) { _logger.LogError(ex.ToString()); ViewBag.Error = "匯出用戶時發生錯誤,請查看LOG!"; return(View("~/Views/Shared/ErrorPage.cshtml")); } }