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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:00:50+00:00 2026-06-15T05:00:50+00:00

Is it possible to create a route without action? I have this default route:

  • 0

Is it possible to create a route without action?

I have this default route:

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

But I also I want to have URLs like this: http://mysite/bar/1234 where 1234 is the ID and bar is the controller.

So I created the following route:

routes.MapRoute(
    name: "BarRoute",
    url: "{controller}/{id}",
    defaults: new { controller = "bar", action = "Index", id = UrlParameter.Optional }
);

But when I navigate to http://mysite/bar/1234, it said the resource is not found. What did I do wrong in the second route?

  • 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-15T05:00:51+00:00Added an answer on June 15, 2026 at 5:00 am

    You cannot have the following 2 routes in that order without any constraints

    • {controller}/{action}/{id}
    • {controller}/{id}

    Those 2 routes are incompatible. When you attempt to access http://mysite/bar/1234, the routing engine is analyzing your routes and /bar/1234 matches your first route. Except that I guess you do not have an action called 1234 on the Bar controller.

    So if you want this setup to work you need to specify some constraints. Also don’t forget that the order of your routes definition is important because they are resolved in the order you defined them. So make sure you place more specific routes at the top.

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

Sidebar

Related Questions

Is this possible to create bundle without default controller and route?
I is it possible to create a url aliasing for a controller/action without creating
I have these routes defined: routes.MapRoute(CategoryList_CountryLanguage, Categories/{id}/{urlCategoryName}/{country}/{language}, new { controller = Categories, action =
I have a route defined with several hardcoded (non-parameter) segments: routes.MapRoute(null, suggestion/list/by/{tag}, new {
Is is possible to create a recursive route in Rails? I have an application,
Possible Duplicate: Create an alert on any view controller after Facebook request:didFailWithError: I have
The default route in MVC {controller}/{action}/{id} is for the most part quite helpful as
Is it possible to create a custom route for GDirections to walk around? Like
Is it possible to define a route in MVC that dynamically resolves the action
I am wondering if it is possible to create a route on a map

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.