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 8016695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:36:45+00:00 2026-06-04T20:36:45+00:00

Currently I have two controllers 1 – Parent Controller 2 – Child Controller I

  • 0

Currently I have two controllers

1 – Parent Controller

2 – Child Controller

I access my Parent Controller like this

someurl\parentcontroller

Now I want to access my children controller like this

someurl\parentcontroller\1\childcontroller

This last url should return all the children of a particular parent.

I have this route currently in my global.asax file

routes.MapHttpRoute ("Route1", "{controller}/{id}", new { id = RouteParameter.Optional });

I am not sure how can I achieve my parent\id\child hierarchy.. How should I configure my routes to achieve this? Ideas?

  • 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-04T20:36:46+00:00Added an answer on June 4, 2026 at 8:36 pm

    Configure the routes as below. The {param} is optional (use if you need):

    routes.MapHttpRoute(
               name: "childapi",
               routeTemplate: "api/Parent/{id}/Child/{param}",
               defaults: new { controller = "Child", param = RouteParameter.Optional }
      );
    
    routes.MapHttpRoute(
             name: "DefaultApi",
             routeTemplate: "api/{controller}/{id}",
             defaults: new { id = RouteParameter.Optional }
      );
    

    Then call the child APi as /api/Parent/1/child
    The parent can be called simple as /api/Parent/

    The child controller:

        public class ChildController : ApiController
        {     
            public string Get(int id)
            {
              //the id is id between parent/{id}/child  
              return "value";
            }
            .......
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
In the iPhone app I'm currently working on, I'd like two view controllers (I'll
I am currently creating an MVC3 application using Ninject. I have two controllers which
I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including
I currently have two panels within another large panel. The left panel is for
I (currently) have two forms, one that needs to call the other. In other
I currently have two threads running in my program: Main thread - Grabs image
We currently have two EC2 servers running apache servers with django wsgi on freebsd.
Is it possible to combine Underscore's filter and map? I currently have two separate
Currently I have two pages: The first page contains an input form, and the

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.