ASP MVC在提交后不重定向

时间:2016-03-28 19:17:52

标签: c# asp.net-mvc vb.net asp.net-mvc-4 controller

我想知道是否可以在提交(Post)之后保留模型内容而不在同一控制器上进行重定向。

场景:我希望用户按下一个按钮,将内容提交到存储库,因此数据库和内容将可用,以便他们可以立即进行编辑 - 我知道我可以编写新方法但是我认为这对我想要的东西有点过分了?

我尝试在ActionResult中没有返回任何内容或null,但页面只是空白。

 ElseIf command = "Save" Then
   Return RedirectToAction("method", "controller", New With {parameters....}    
 ElseIf command = "Apply" Then
//I want the page to remain static so they can edit straight away
   Return Nothing

任何建议都会有所帮助

由于

1 个答案:

答案 0 :(得分:2)

成功提交重定向后编辑视图

return RedirectToAction("Edit","ControllerName", new { id = match.MatchID });

如果编辑中有一些错误

return View();

如果你想在表单中使用ajax行为,你可以使用

Ajax.BeginForm("UpdateEmail", "Ajax", new AjaxOptions...

您可以看到此link了解详情