private member in controller returns null after being set in action result

前端 未结 1 537
情歌与酒
情歌与酒 2021-01-26 07:37

I have a controller in ASP.NET MVC application.

private GipDbContext db = new GipDbContext();
private Employee employeeObj;

public ActionResult Edit(int? id)
          


        
相关标签:
1条回答
  • 2021-01-26 08:15

    Controllers are instantiated for each request. Once you request TimeSeriesData, the controller that was created for the request to Edit has already been disposed. If you need to hold on to a piece of data between requests, you must either put it in Session or TempData (both of which use sessions).

    0 讨论(0)
提交回复
热议问题