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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:27:33+00:00 2026-06-17T17:27:33+00:00

If I have the following MapRoute: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL

  • 0

If I have the following MapRoute:

routes.MapRoute(
    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL with parameters
        new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
);

I can have an url like:

blabla.com/Home/Index/123

But what kind of MapRoute do I need to create to be able to do this:

blabla.com/Home/123 or blabla.com/Home/DEADBEEF?

I imagine it involves something along the lines of
"{controller}/{id}/{action}"

Action and id are reversed, and maybe there should be a default action. But how will the MapRoute know which controller should be treated like this?

  • 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-17T17:27:34+00:00Added an answer on June 17, 2026 at 5:27 pm

    You probably need something along these lines.

      routes.MapRoute(
          name: "DefaultRoute",
          url: "Home/{action}",
          defaults: new { controller = "Home", action = "Index" },
          constraints: new { action = "[A-Za-z]*" }
      );
    

    or without an action

      routes.MapRoute(
          name: "DefaultRoute",
          url: "Home/{id}",
          defaults: new { controller = "Home", action = "Index", id = "" },
          constraints: new { id = "[A-Za-z]*" }
      );
    

    You will need to make sure that the route name is different than any other routes you have setup and pay attention to the ordering of the routes as other routes that are similar can override each other. In this case make sure you would probably want this before the default route but be aware that it will override it.

    As for the not having controller or even the action you can set defaults and do not need them within the route.

    As for constraints you can simply add the constraints parameter to the route to set a regular expression for a certain attribute as shown above.

    EDIT:
    Here are some useful links for more info on routing if you need it.

    • http://www.dotnet-tricks.com/Tutorial/mvc/HXHK010113-Routing-in-Asp.Net-MVC-with-example.html
    • http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx
    • Advanced ASP Routing tutorials and examples
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following route: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL with
Suppose I have the following routing routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL
I have the following route: routes.MapRoute( Default, // Route name {language}/{controller}/{action}/{id}, new { language
I have the following default and only route: routes.MapRoute( Default, // Route name {controller}/{action}/{id},
Let's say I have the following rule routes.MapRoute( Default, // Route name {controller}/{action}/{id}, //
I have the following URl: http://localhost:12981/BaseEvent/EventOverview/12?type=Film This is route: routes.MapRoute( Default, // Route name
HI I have the following routing table routes.MapRoute(null, Save, // Route name new {
I have the following routes defined for my application: routes.MapRoute( Referral, // Route name
Why doesn't this work? Route: routes.MapRoute( Summary, {controller}/{id}, new { controller = Summary, action
I have the following route's defined: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute(

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.