pass data from Action To Another Action

前端 未结 1 647
醉酒成梦
醉酒成梦 2021-01-13 10:04

How would you pass the model from an (GetDate) action to another (ProcessP) action via RedirectAction method?

Here\'s the source code:

[HttpPost]
pub         


        
1条回答
  •  伪装坚强ぢ
    2021-01-13 10:40

    If you need to pass data from one action to another one option is to utilize TempData. For example within GetDate you could add data to the session as follows:

    TempData["Key"] = YourData
    

    And then perform the redirect. Within ProcessP you can access the data utilizing the key you previously used:

    var whatever = TempData["Key"];
    

    For a decent read, I would recommend reading through this thread: ASP.NET MVC - TempData - Good or bad practice

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