我的项目结构是这样的:
- 控制器/ArticlesController.cs
- 控制器/评论Controller.cs
- 视图/文章/Read.aspx
read.aspx 带一个参数say“output”,是文章的详细信息,通过id和评论,从ArticlesController.cs
现在我想写然后阅读评论:: write()
& Read()
funct inCommentsController.cs
为了阅读带有评论的文章,我想通过传递输出参数来调用Views/Articles/Read.aspx
fromCommentsController.cs
CommentsController.cs
我怎样才能做到这一点?
更新
代码在这里:
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);
}
}