如何为搜索和结果创建ActionResults,无法弄清楚

时间:2016-02-25 20:05:13

标签: c# linq actionresult

我正在尝试创建搜索和结果页面。第一个UserTotalTimeSpentReport()函数返回ActionResult,它是一个Search页面。然后,用户进行一些选择并发布页面。然后,它将转到第二个UserTotalTimeSpentReport(),其中包含[HttpPost]标记。在第二个UserTotalTimeSpentReport中,我执行复杂的LINQ查询并生成结果。我不知道如何显示该结果,因为它与ActionResult相同。我需要将用户转发到另一个页面。这样做的正确方法是什么?

public ActionResult UserTotalTimeSpentReport()
{
    UserTotalTimeSpentModel model = new UserTotalTimeSpentModel();
    return View(model);
}

[HttpPost]
public ActionResult UserTotalTimeSpentReport(string AntsoftCrmUser, DateTime? StartDate, DateTime? EndDate) 
{
 .....
 .....
 return View(result)
}

1 个答案:

答案 0 :(得分:0)

如果这是你的另一种观点,那么这就是要走的路:

[HttpPost]
public ActionResult UserTotalTimeSpentReport(string AntsoftCrmUser, DateTime? StartDate, DateTime? EndDate) 
{
 .....
 .....
 return View("the name of your view here", result)
}

您可以阅读有关视图方法here

的不同重载的更多信息