2014-02-19 26 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 
}