Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MVC RedirectToAction正在重定向到其他方法_C#_Asp.net Mvc - Fatal编程技术网

C# MVC RedirectToAction正在重定向到其他方法

C# MVC RedirectToAction正在重定向到其他方法,c#,asp.net-mvc,C#,Asp.net Mvc,在我的控制器中,我有三种方法: public ActionResult DisplayPostsComments() { var viewModel = new DisplayPostsCommentsWiewModel(); return View(viewModel); } [HttpPost] public ActionResult DisplayPostsComments(DateTime start, Date

在我的控制器中,我有三种方法:

    public ActionResult DisplayPostsComments()
    {
        var viewModel = new DisplayPostsCommentsWiewModel();
        return View(viewModel);
    }


    [HttpPost]
    public ActionResult DisplayPostsComments(DateTime start, DateTime end)
    {
        List<PostModel> postList = new List<PostModel>();
        var posts = postDAL.GetPost(start, end);
        var comments = commentDAL.GetComments(posts);
        var viewModel = new DisplayPostsCommentsWiewModel(posts, comments);
        viewModel.start = start;
        viewModel.end = end;
        return View(viewModel);
    }


    public ActionResult DeleteComment(int commentId, DateTime start, DateTime end)
    {
        // commentDAL.DeleteComment(commentId);
        return RedirectToAction("DisplayPostsComments", new { start = start, end = end });
    }
}

使用参数调用第二个方法。但是我实现了对第一个方法的调用。我做错了什么?

重定向将302重定向响应返回给客户端,迫使客户端向提供的位置发出GET请求


您的操作是POST,但不用于路由。

为什么不调用DisplayPostsComments方法本身?请注意,模型视图控制器标记用于询问有关模式的问题。ASP.NET-MVC实现有一个特定的标记。
return RedirectToAction("DisplayPostsComments", new { start = start, end = end });