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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:32:00+00:00 2026-05-12T23:32:00+00:00

For a scenario, I have a ASP.NET MVC application with URLs that look like

  • 0

For a scenario, I have a ASP.NET MVC application with URLs that look like the following:

http://example.com/Customer/List
http://example.com/Customer/List/Page/2
http://example.com/Customer/List
http://example.com/Customer/View/8372
http://example.com/Customer/Search/foo/Page/5

These URLs are achieved with following routes in Global.asax.cs

routes.MapRoute(
    "CustomerSearch"
    , "Customer/Search/{query}/Page/{page}"
    , new { controller = "Customer", action = "Search" }
);

routes.MapRoute(
    "CustomerGeneric"
    , "Customer/{action}/{id}/Page/{page}"
    , new { controller = "Customer" }
);

//-- Default Route
routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Customer", action = "Index", id = "" }
);

These all have gone well until a new requirement arrived and wants to drop keyword ‘Customer’ off the URL, to make the URLs look like:

http://example.com/List
http://example.com/List/Page/2
http://example.com/List
http://example.com/View/8372
http://example.com/Search/foo/Page/5

Edit: corrected example links, thanks to @haacked.

I tried to add new MapRoutes to take {action} only and have default controller set to Customer. eg/

routes.MapRoute(
    "CustomerFoo"
    , "{action}"
    , new { controller = "Customer", action = "Index" }
);

This seems to work, however now all links generated by Html.ActionLink() are weird and no longer URL friendly.

So, is this achievable? Am I approaching in the right direction?

  • 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-05-12T23:32:01+00:00Added an answer on May 12, 2026 at 11:32 pm

    don’t mix a rule like: "{action}/{id}" with one that’s "{controller}/{action}/{id}" … specially when id in the later has a default value i.e. is optional.

    In that case you have nothing that allows routing to know which one is the right one to use.

    A workaround, if that’s what you need, would be to add a constrain (see this) to the action in the earlier to a set of values i.e. List, View. Of course that with these types of rules, you can’t have a controller with the same name of an action.

    Also remember that if you specify a default action & id in the "{action}/{id}" rule, that will be used when you hit the route of your site.

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

Sidebar

Related Questions

Scenario : I have an ASP.NET MVC application developed in Visual Studio 2008. There
I have an ASP.NET MVC application that uses LINQ2SQL as the database layer. I
I have an ASP.NET MVC web application that makes REST style web service calls
I have a simple ASP.NET MVC web application that uses NHibernate with FluentNHibernate's auto
Scenario: You have an ASP.Net webpage that should display the next image in a
Here's the scenario: You have an ASP.Net application supported by a Microsoft SQL Server
I have a scenario where users of my ASP.NET web application submit testimonials consisting
So I have a layered ASP.NET MVC proof-of-concept application with good separation between presentation
We are working with an asp.net mvc app that is shared by multiple clients.
As I am learning and working on Asp.Net MVC application, I want to know

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.