这位于搜索控制器
中public ActionResult Index(string what, string where, int page = 1, string cn = "", string sv = "", string ch = "", string deals = "", int brand = 0)
这是我的第二个名为Quotaion的控制器,我想传递上述控制器的参数值,但是我将它们硬编码为搜索管道工,那么我如何将它们从搜索控制器动态传递到报价控制器
public ActionResult Index()
{
WhereInfo interLoc = new WhereInfo();
// SearchService.ResultSet resultSet = (neSearchService.Search()).getSearchResults("plumbers", interLoc, 1.ToString(), User.Identity.Name, "iyp", "", "", "", "", "", "plumbers", 0);
// ViewBag.Search = resultSet;
// return View();
}
答案 0 :(得分:1)
重定向到另一个控制器?
return RedirectToAction("Index", "Quotation", new { what = whatParam, where = whereParam, page = pageParam, cn = cnParam, sv = svParam, ch = chParam, deals = dealsParam, brand = brandParam });
或者,将数据放入TempData [],但此存储仅在请求期间有效。
答案 1 :(得分:0)
尝试使用TempData
public ActionResult Index(string what, string where, int page = 1, string cn = "", string sv = "", string ch = "", string deals = "", int brand = 0)
{
TempData["details"] = your_variable_with_details;
return RedirectToAction("OtherAction");
}
在QuotationController中,测试TempData["details"]
是否为空。
public ActionResult Index()
{
if(TempData["details"]!=null){
// do something here
}
}
TempData用于传递简单数据而不将数据暴露给客户端