【问题标题】:How to create ActionResults for Search and Result, cannot figure out如何为搜索和结果创建 ActionResults,无法弄清楚
【发布时间】:2016-02-25 20:05:12
【问题描述】:

我正在尝试创建搜索和结果页面。第一个UserTotalTimeSpentReport() 函数返回ActionResult,它是一个搜索页面。然后,用户进行一些选择并发布页面。然后,它会转到第二个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)
}

【问题讨论】:

    标签: c# linq actionresult


    【解决方案1】:

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

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

    您可以阅读更多关于视图方法here的不同重载

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-26
      • 1970-01-01
      • 2014-09-03
      • 1970-01-01
      • 2014-12-18
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      相关资源
      最近更新 更多