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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:44:01+00:00 2026-06-04T10:44:01+00:00

I am attempting to create some custom map routes but can’t get it working

  • 0

I am attempting to create some custom map routes but can’t get it working quite right.

My ultimate aim is to be able to specify something like the following. Where by I essentially have my URL constructed with value pairs of “id” and “name”. The name is irrelevant and solely for user pleasantries, I will require the ID in my controller though.

/dashboards/5-My-Estate-name/89-My-subgroup-name/133-Maybe-even-another-subgroup

For starters I’m working on the first section and having troubles.

Browsing to “http://localhost:53933/dashboards/109-building-xyz” whilst using the following route generates the error A public action method '109-building-xyz' was not found on controller 'MyInterfaceInterface.Controllers.DashboardsController'.

routes.MapRoute(
  "Dashboard",
  "dashboards/{id}-{name}", // URL pattern
   new { controller = "Dashboards", action = "Index" },
   new { id = @"\d+", name = UrlParameter.Optional }
);

Obviously I wanted this to be routed to the Index function with parameters.

What am I doing wrong? Am I even structuring this correctly? I come from a web-PHP background and using htaccess to achieve such things.

Thanks

  • 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-04T10:44:03+00:00Added an answer on June 4, 2026 at 10:44 am

    The order of routes matter. MVC will match the first declared route with a pattern that matches the URL pattern.

    So if you have this:

    routes.MapRoute(
      "Default",
      "{controller}/{action}/{id}", // URL pattern
       new { controller = "Home", action = "Index" },
       new { id = UrlParameter.Optional }
    );
    routes.MapRoute(
      "Dashboard",
      "dashboards/{id}-{name}", // URL pattern
       new { controller = "Dashboards", action = "Index" },
       new { id = @"\d+", name = UrlParameter.Optional }
    );
    

    Then what will happen with the URL http://localhost:53933/dashboards/109-building-xyz is that MVC will match “dashboards” to the controller and “109-building-xyz” to the action.

    You need to always declare your most specific routes first, and more general routes afterward, like so:

    routes.MapRoute(
      "Dashboard",
      "dashboards/{id}-{name}", // URL pattern
       new { controller = "Dashboards", action = "Index" },
       new { id = @"\d+", name = UrlParameter.Optional }
    );
    routes.MapRoute(
      "Default",
      "{controller}/{action}/{id}", // URL pattern
       new { controller = "Home", action = "Index" },
       new { id = UrlParameter.Optional }
    );
    

    However, Morten Mertner is right in his comment — I don’t think you can have 2 route parameters that are not separated by a forward slash. You would need to change your URL pattern to something like this in order to use it with the default routing engine:

    "dashboards/{id}/{name}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I attempting to create custom tabs using this . But when I try to
I am attempting to create some functionality on beta.peaksneak.com where users can basically journalize.
I am attempting to create a custom messaging app. Just something basic but I
I'm fairly new to Ruby on Rails, and I'm attempting to create some fancy
Some background: I am attempting to create a DirectShow source filter based on the
I am attempting to create a very simple web interface for changing some system
I am attempting to create a keyboard hook to use in Java. After some
I am attempting to create python bindings for some C++ code using swig. I
I'm attempting to create a job using DBMS_SCHEDULER in an Oracle 11g DB but
I am attempting to do some custom email forwarding. #1 I am on a

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.