0

In my controller I have three methods:

    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 });
    }
}

I expect

return RedirectToAction("DisplayPostsComments", new { start = start, end = end });

to call the second method with parameters. But what I've achieved is a call to the first method. What I'm doing wrong?

Zet
  • 571
  • 3
  • 13
  • 31
  • Why not call the method DisplayPostsComments itself? –  Mar 15 '17 at 08:31
  • 1
    Please note that the model-view-controller tag is for questions about the pattern. There is a specific tag for the ASP.NET-MVC implementation. –  Mar 15 '17 at 09:12

1 Answers1

2

Redirect returns "302 Redirect" response to client, forcing it to make GET request to provided location.

Your action is POST and though is not used for routing.

Lanorkin
  • 7,310
  • 2
  • 42
  • 60