1
[HttpGet]
        public ActionResult BookingStep1()
        {
           return View(new BookingMainApplicantInfo());
        }

 [HttpPost]
        public ActionResult BookingStep1(BookingMainApplicantInfo mainApplicant)
        {
          return View(mainApplicant);
        }

  [HttpGet]
        public ActionResult BookingStep12()
        {
           //how to fetch data from above step 2 to here
            return View();
        }

方案是将会员数据发送到下一步,即下一个操作结果,我将计算发票并提供付款选项。

我应该使用会话还是应该将其保存到数据库?

4

1 回答 1

0

我应该使用会话还是应该将其保存到数据库?

你应该把这些作为最后的选择。以下是我的建议。

  1. 临时数据
  2. 重定向到动作

TempData - 这就像一个DataReader. 读取密钥后,数据将变为空。如果您在读取数据后仍想保留数据,可以使用如下代码

TempData.Alive()

Alive即使在TempData读取特定键后,函数也会保留数据。

RedirectToAction - 在这种方法中,您可以在参数列表中设置查询字符串值。下面是示例代码。

return RedirectToAction( "Action Name", 
                             new RouteValueDictionary
                             ( 
                                   new 
                                   { 
                                        controller = controllerName, 
                                        action = "Action Name", 
                                        QueryStringKey = "Query String Value" 
                                   } 
                             )    
                       );
于 2013-06-08T18:06:33.590 回答