0
In meinem Controller Ich habe drei Methoden:MVC RedirectToAction auf andere Methode Umleitung
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
return RedirectToAction("DisplayPostsComments", new { start = start, end = end });
erwarten, dass die zweite Methode mit Parametern aufzurufen. Aber was ich erreicht habe, ist ein Aufruf an die erste Methode. Was mache ich falsch?
Warum nicht die Methode DisplayPostsComments selbst aufrufen? –
Bitte beachten Sie, dass das Model-View-Controller-Tag für Fragen zum Muster dient. Es gibt ein bestimmtes Tag für die ASP.NET-MVC-Implementierung. –