简体   繁体   English

提交后ASP MVC不会重定向

[英]ASP MVC doesn't redirect after submit

I am wondering if its possible to keep the model content after a submit (Post) without a redirection on the same controller. 我想知道是否有可能在提交(发布)后保留模型内容而无需在同一控制器上进行重定向。

The scenario: I want the user to press a button that will submit the content to the repository and therefore database and the contents will be available so they can go and edit it straight away - I know i can code a new method but I think this is overkill for what I want? 场景:我希望用户按下将内容提交到存储库的按钮,因此数据库和内容将可用,以便他们可以立即对其进行编辑-我知道我可以编写一种新方法,但是我认为对我想要的东西过度杀伤?

I have tried returning nothing or null in the ActionResult but the page just goes blank. 我尝试在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

Any advice would be helpful 任何意见将是有益的

Thanks 谢谢

after successful submit redirect to edit View 成功提交后重定向到编辑视图

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

and if there is some error in edit that do 如果在编辑时出现错误

return View();

and if you want to use ajax behaviour in form you can use 如果您想以表格形式使用ajax行为,可以使用

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

you can see this link for details 您可以查看此链接以获取详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM