public ActionResult Balance(ViewModelClass.BalancingFormModel obj, string download) { if (Session["User"] == null) { return(RedirectToAction("LogIn", "LogIn")); } if (((tbl_UserDetail)Session["User"]).GroupPages.Contains("Balance")) { try { TempData["List"] = MvcHelper.GetBalanceList(obj.fromdate, obj.todate, obj.terminalId, obj.GlAccoungt); TempData["obj"] = obj; List <ViewModelClass.ViewBalancingModel> transactionlist = new List <ViewModelClass.ViewBalancingModel>(); transactionlist = MvcHelper.GetBalanceList(obj.fromdate, obj.todate, obj.terminalId, obj.GlAccoungt); if (!string.IsNullOrEmpty(download)) { string sheetname = "BalanceReport" + DateTime.Now; FormattoExcel(transactionlist, sheetname); } } catch (Exception ex) { TempData["Error"] = "Something went wrong."; } return(RedirectToAction("Balance")); } else { return(RedirectToAction("Error", "ErrorPage")); } }