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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:34:03+00:00 2026-06-10T02:34:03+00:00

I have an ASP.Net application which has an area called ‘Customers’. This area has

  • 0

I have an ASP.Net application which has an area called ‘Customers’. This area has a controller with the same name with a single method called Index.

I have the following route defined:

context.MapRoute(null,
    "Customers/{controller}/{action}",
    new { controller = "customers", action = "Index" }
);

This allows my to navigate to use the following URL to navigate to the index method on my Customers controller.

MyDomain/Customers

In my customer area I also have another controller called products. This has a number of methods that allow me to work with product entities (mostly auto-generated by Visual Studio at the moment).

With my current route I can navigate to the products controller using URL’s like this:

MyDomain/Customers/Products (shows the index page of the products
controller) MyDomain/Customers/Products/Create (Shows a page to add
new products). MyDomain/Customers/Products/Details?id=1234 (Show the
product with the id of 1234)

Now what I want to be able to do is navigate to the details page with a much more user friendly URL such as:

MyDomain/Customers/Products/1234

I have defined a new route that look like this:

context.MapRoute(null,
    "Customers/Products/{id}",
    new { controller = "Products", action = "Details" }
    );

The route is defined before the first route I demonstrated.
This allows me to navigate to the products page as I want, however I can no longer navigate to other methods on my products controller.

E.G. The following URL

MyDomain/Customers/Products/Create

Gives me the following error:

The parameters dictionary contains a null entry for parameter ‘id’ of
non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ViewResult
Details(Int32)’

If I change the order of the routes then I can navigate to all the methods on my products controller but my details URL reverts to the old format of having a query parameter.

If I update the route to look like this:

context.MapRoute(null,
    "Customers/Products/{id}",
    new { controller = "Products", action = "Details", id = UrlParameter.Optional }
    );

Then I still get the same problem.

Can anyone tell me how to structure my routes to get the result I want? In summary:

  1. If I navigate to the Customers area I want my URL to look like ‘MyDomain/Customers’
  2. If I navigate to the product details page I want my URL to look like “MyDomain/Customers/Products/1234”.
  3. If I navigate to any other product page I want my URL to look like ‘MyDomain/Customers/Products/Create’
  • 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-10T02:34:05+00:00Added an answer on June 10, 2026 at 2:34 am

    If the ID is always going to be an int then you can add a constraint to the route like this:

    context.MapRoute(null,
                     "Customers/Products/{id}",
                     new {controller = "Products", action = "Details", id = UrlParameter.Optional},
                     new {id = @"\d+"} // Constraint to only allow numbers
                    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC 3 application which has a post action called Create
I have a ASP.NET web application which has more than 100 pages. Each page
I have an ASP.NET web application project which references another project called ModusCore (or
I have one asp.net application, which has some problems while i am entering the
I have a asp.net application which is working from last 2-3 years, it has
I have a ASP.NET MVC application which has a view populated with a model
I have a basic ASP.Net MVC 3 application which has a number of controllers
Can anyone help. I have an ASP.NET application which has a web.config file so
Here's the scenario I have an ASP.NET 4.0 application which has a LOT of
I have a asp.net web application which has a number of versions deployed on

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.