2014-02-19 27 views
2

我在同一個控制器中創建了兩個視圖。問題是,我想在httppost完成後加載第二個視圖。ASP.NET MVC返回httpPost後的索引視圖

索引視圖

public ActionResult Index() 
{ 
    return View(); 
} 

HttpPost

[HttpPost] 
public ActionResult Index(AccountModel model) 
{ 

    return View("NEXTVIEW"); 

} 

下一頁查看

public ActionResult NEXTVIEW(EpmloyeeModal model) 
{ 
    return View(); 
} 

後HttpPost,我有廣告ded返回到nextview。而它總是返回到索引視圖。我試圖在不同的網站上找到這樣的場景,但找不到任何地方。

謝謝。

回答

11

嘗試這樣

[HttpPost] 
public ActionResult Index(AccountModel model) 
{ 
    return RedirectToAction("NEXTVIEW"); 
} 
5

對於後期操作,使用此:

[HttpPost] 
public ActionResult Index(AccountModel model) 
{ 
    return RedirectToAction("NEXTVIEW"); 
} 
+0

哦,我遲到了;( –

3

你的下一個視圖操作期待一個模型,你需要通過它的EpmloyeeModal模型

[HttpPost] 
public ActionResult Index(AccountModel model) 
{ 
    return RedirectToAction("NEXTVIEW",new EpmloyeeModal()); 
} 
5

郵政使用,以下內容:

[HttpPost] 
public ActionResult Index(AccountModel model) 
{ 
    return RedirectToAction("NEXTVIEW"); // Redirect to your NextView 
}