Моя структура проекта похожа:
- Контроллеры /ArticlesController.cs
- Контроллеры /CommentsController.cs
- Просмотров/Статьи/Read.aspx
Read.aspx принимает параметр say "output", который является деталями статьи по id и ее комментариям, переданным из ArticlesController.cs
Теперь я хочу написать, а затем читать комментарии:: write()
и Read()
funct в CommentsController.cs
Для чтения статьи с ее комментариями я хочу вызвать Views/Articles/Read.aspx
из CommentsController.cs
, передав выходной параметр из CommentsController.cs
Как я могу это сделать?
UPDATE
Код здесь:
public class CommentsController : AppController
{
public ActionResult write()
{
//some code
commentRepository.Add(comment);
commentRepository.Save();
//works fine till here, Data saved in db
return RedirectToAction("Read", new { article = comment.article_id });
}
public ActionResult Read(int article)
{
ArticleRepository ar = new ArticleRepository();
var output = ar.Find(article);
//Now I want to redirect to Articles/Read.aspx with output parameter.
return View("Articles/Read", new { article = comment.article_id });
}
}
public class ArticlesController : AppController
{
public ActionResult Read(int article)
{
var output = articleRepository.Find(article);
//This Displays article data in Articles/Read.aspx
return View(output);
}
}