【发布时间】:2017-08-05 21:03:31
【问题描述】:
在我的控制器中,我有三种方法:
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 });
用参数调用第二种方法。但我所取得的是对第一种方法的调用。我做错了什么?
【问题讨论】:
-
为什么不自己调用 DisplayPostsComments 方法呢?
-
请注意,model-view-controller 标签是针对有关模式的问题。 ASP.NET-MVC 实现有一个特定的标记。
标签: c# asp.net-mvc