Ras*_*sto 5 c# asp.net url asp.net-mvc redirect
在ASP.NET MVC中,我有一个看起来像这样的控制器:
public class MyController{
    public ActionResult Index(){
        return View(new MyModel());
    }
    [HttpPost]
    public ActionResult Index(MyModel model){
        //do something
        return View("RegistrationConfirmation", new ConfirmModel());
    }
    [HttpPost]
    public ActionResult RegistrationConfirmation(ConfirmModel model){
        //do something else
        return View();
    }
}
我希望用户的工作流程如下
GET页面索引.返回视图Index.网址:~/MyPOST索引页面中的数据 - 返回视图RegistrationConfirmation并将用户发送到右页~/My/RegistrationConfirmation.POST在RegistrationConfirmation页面上的另一个数据,以便RegistrationConfirmation调用它们来处理它们.现在RegistrationConfirmation从不调用action方法,因为在RegistrationConfirmation通过Index操作方法返回视图后,URL保持不变,~/My因此第二个帖子由Index(MyModel)action方法而不是RegistrationConfirmation(ConfirmModel)action方法处理.
如何更改URL以及发送View以便在POST后面调用与视图对应的控制器操作?或者还有其他方法可以确保调用相应的控制器吗?
注意:在发布这个问题之前,我确实已经阅读了20多个关于主题的问题.我认为对他们中任何一个人的完美答案都不会给我解决方案.请在投票前正确阅读以复制为准.
在 RegistationConfirmation 视图中尝试这个
您可以轻松添加应在 Html.BeginnForm 命令中定位的操作和控制器...
   <% using(Html.BeginForm("RegistrationConfirmation", "MyController")){%>
    //form elements
   <%}%>
这样您就可以准确定义要调用哪个操作和控制器