Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC Calling a view from a different controller
    primarykey
    data
    text
    <p>My project structure is like:</p> <ul> <li>Controllers/ArticlesController.cs </li> <li>Controllers/CommentsController.cs</li> <li>Views/Articles/Read.aspx</li> </ul> <p>Read.aspx takes a parameter say "output", which is the details of the article by id and its comments, passed from <code>ArticlesController.cs</code></p> <p>Now I want to write then read the comment:: <code>write()</code> &amp; <code>Read()</code> funct in <code>CommentsController.cs</code></p> <p>For reading the article with its comments, I want to call <code>Views/Articles/Read.aspx</code> from <code>CommentsController.cs</code> by passing output parameter from <code>CommentsController.cs</code></p> <p>How can I do this?</p> <h2><strong>UPDATE</strong></h2> <p>Code Here:</p> <pre><code>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); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload