2016-02-25 61 views
0

我正在嘗試創建搜索和結果頁面。第一個UserTotalTimeSpentReport()函數返回一個搜索頁面的ActionResult。然後,用戶做一些選擇併發布頁面。然後,它將轉到第二個UserTotalTimeSpentReport(),其中有[HttpPost]標記。在第二個UserTotalTimeSpentReport中,我執行一個複雜的LINQ查詢併產生一個結果。我不知道如何顯示該結果,因爲它採用相同的ActionResult。我需要將用戶轉到另一個頁面。這樣做的正確方法是什麼?如何爲搜索和結果創建ActionResults,無法找出

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

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

回答

0

如果這是你的意思是另一種看法,那麼這是要走的路:

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

你可以閱讀更多有關視圖方法的不同重載here