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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:35:35+00:00 2026-06-19T03:35:35+00:00

I’ve managed to get my Home controller working by only using the action name

  • 0

I’ve managed to get my Home controller working by only using the action name to access it, but as soon as I add another controller and try do the same thing by adding another route declaration the same at my Home route declaration, all the routes default to the Home controller.

routes.MapRoute("HomeTest", "{action}/{id}", new { controller = "Home", action = "TestHome", id = UrlParameter.Optional });
routes.MapRoute("TestTest", "{action}/{id}", new { controller = "Test", action = "Test", id = UrlParameter.Optional });


public class HomeController : Controller
{
    public ActionResult TestHome(int? id)
    {
        return View();
    }
}

public class TestController : Controller
{
    public ActionResult Test(int? id)
    {
        return View();
    }
}

Is there any way I can access both controllers without including the controller name in the url?

I also have the default route included if that makes any difference. It’s under these two routes.

  • 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-19T03:35:36+00:00Added an answer on June 19, 2026 at 3:35 am

    Routes in MVC are compared in the order you add them. For your code sample, this means that all requests will be compared to the “HomeTest” route first, so any matches will follow that route. The “TestTest” route has the exact same format, which means that it will never be used because any matches will have already used the “HomeTest” route. If you want to get to get to a controller’s actions without using the controller name, there must be something in the route to tell it which controller to use. This doesn’t have to be the actual controller name – you can do this:

    routes.MapRoute("TestTest", "keyWord/{action}/{id}", new { controller = "Test", action = "Test", id = UrlParameter.Optional });
    routes.MapRoute("UsersTest", "otherKeyWord/{action}/{id}", new { controller = "Users", action = "Test", id = UrlParameter.Optional });
    

    where the keywords basically act as aliases to hide your controller names. You can even go one step further and mask your action names as well, which can let you use multiple controllers under one URL root:

    routes.MapRoute("TestTest", "test/key1/{id}", new { controller = "Test", action = "Test", id = UrlParameter.Optional });
    routes.MapRoute("UsersTest", "test/key2/{id}", new { controller = "Users", action = "Test", id = UrlParameter.Optional });
    

    Doing something like this can let you give your users a much tidier URL structure to help them navigate your site and understand where links will take them (potentially also handy for bookmarking) but it does mean you have to manually define your URLs, which is more work.

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

Sidebar

Related Questions

I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.