在我的控制器中,我有三种方法:
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 });
}
}
我希望
return RedirectToAction("DisplayPostsComments", new { start = start, end = end });
用参数调用第二个方法。但我所取得的是对第一种方法的调用。我做错了什么?
答案 0 :(得分:1)
重定向向客户端返回“302 Redirect”响应,强制它向提供的位置发出GET请求。
您的操作是POST,但不用于路由。