Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:56:16+00:00 2026-06-09T20:56:16+00:00

My project structure is like: Controllers/ArticlesController.cs Controllers/CommentsController.cs Views/Articles/Read.aspx Read.aspx takes a parameter say output,

  • 0

My project structure is like:

  • Controllers/ArticlesController.cs
  • Controllers/CommentsController.cs
  • Views/Articles/Read.aspx

Read.aspx takes a parameter say “output”, which is the details of the article by id and its comments, passed from ArticlesController.cs

Now I want to write then read the comment:: write() & Read() funct in CommentsController.cs

For reading the article with its comments, I want to call Views/Articles/Read.aspx from CommentsController.cs by passing output parameter from CommentsController.cs

How can I do this?

UPDATE

Code Here:

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);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:56:17+00:00Added an answer on June 9, 2026 at 8:56 pm

    To directly answer your question if you want to return a view that belongs to another controller you simply have to specify the name of the view and its folder name.

    public class CommentsController : Controller
    {
        public ActionResult Index()
        { 
            return View("../Articles/Index", model );
        }
    }
    

    and

    public class ArticlesController : Controller
    {
        public ActionResult Index()
        { 
            return View();
        }
    }
    

    Also, you’re talking about using a read and write method from one controller in another. I think you should directly access those methods through a model rather than calling into another controller as the other controller probably returns html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure like this WebUI project - controllers, views Framework project- repositories,service
I have a project structure like this... app/ main.py app/ __init__.py boot.py server.py controllers/
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
I have a project structure like: src/CMakeLists.txt src/test/component1/CMakeLists.txt src/test/component2/CMakeLists.txt For the testing, I'm using
I have a project with a structure like this: project code art config Art
Is this possible in any way? My project folder structure looks like this: my_project:
I have an Xcode project with a directory structure like this: MasterProjectDir/projectname.xcodeproj MasterProjectDir/ProjectSubDir/whatever.c MasterProjectDir/ProjectSubDir/etc.c
In an ASP.NET MVC3 project I have a structure like this: Core.csproj -> 3rdparty1.dll
When applying a multi-project Gradle structure to our project, my settings.gradle looks like this:
I have a structure like follows: /application ..... --/modules ----/structure ------/controllers --------/indexController.php ------/forms --------/Department.php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.