Я пытаюсь сохранить List
в TempData, который я позже приведу к его типу и передам в представление, но TempData после возврата из контроллера теряет свои данные.
Контроллер A:
public ActionResult Index(int? Page, int? id, int? attId, int? EnrollNumber, int? attend, DateTime? reqDate, DateTime? reqDT, DateTime? reqTime, DateTime? StartDate, string deets = " ", string preAppr = "", string type = "")
{
//some code
new UserInfoController().reLabelLogs(reqTime.Value.Date, reqTime.Value, id, 0, 0, null, attLogs);
var atLogs = new List<AttendanceLog>();
var temp = TempData["ppList"]; //its empty?
atLogs = (List<AttendanceLog>)TempData["ppList"];
return View(atLogs);
}
Контроллер UserInfo:
public void reLabelLogs(DateTime? startDate, DateTime? startDateTime, int? empId, int? isPending, int? isManual, DateTime? manualDate
, List<AttendanceLog> pList)
{
//some code
if (pList == null)
{
data = db.AttendanceLogs
.Where(z => z.EmpID == empId && z.Date >= startDate && z.Date <= today).ToList();
}
else
{
noSave = true;
data = pList.ToList();
}
foreach (var log in data)
{
// some code
}
TempData["ppList"] = data; //there is data but soon after the control goes back to Controller A it becomes null
}
Что я пробовал?
Я пытался использовать:
Session (but it would give NullException at UserInfoController)
ViewBag.ppList (same result as TempData)
Tried TempData.Keep(); and TempData.Peek(); (no help)
