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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:19:14+00:00 2026-06-15T13:19:14+00:00

I am altering an ASP.NET, MVC, C# application but a routes.MapRoute entry isn’t working

  • 0

I am altering an ASP.NET, MVC, C# application but a routes.MapRoute entry isn’t working as expected. In my Global.asax.cs file I have the following two routes –

routes.MapRoute(
            "MyRoute1", // Route name
            "{controller}/{action}/{something}/{name}/{id}/{myParameterA}", 
            new { controller = "MyController", action = "MyActionA", category = "something", name = "name", id = "id", myParameterA = "myParameterA" });


routes.MapRoute(
            "MyRoute2", // Route name
            "{controller}/{action}/{something}/{name}/{id}/{myParameterB}", 
            new { controller = "MyController", action = "MyActionB", category = "something", name = "name", id = "id", myParameterB = UrlParameter.Optional } );

The code in my controller looks like this –

    public ActionResult MyActionA(string something, string name, string id, string myParameterA)
    {
       //do cool stuff!
    }

    public ActionResult MyActionB(string something, string name, string id, string myParameterB)
    {
       //do awesome stuff!
    }

When I call MyActionB, the final parameter myParameterB is coming into the Controller as null even when the parameter is in the URL – (example: /MyController/MyActionB/aThing/aName/123/456).

I do want the final parameter (‘456’ in my above example) to be optional.

MyActionA is working fine.

Any suggestions would be appreciated!
Also, is there a good reference out there on how routes.MapRoute works?
Thank you!

  • 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-15T13:19:15+00:00Added an answer on June 15, 2026 at 1:19 pm

    This is because there is nothing to distinguish between those 2 routes once you replace the parameters with strings in the route itself. If you add a static part to the routes you should be able to differentiate between them.

    routes.MapRoute(
            "MyRoute1", // Route name
            "{controller}/{action}/{something}/{name}/{id}/firstroute/{myParameterA}", 
            new { controller = "MyController", action = "MyActionA", category = "something", name = "name", id = "id", myParameterA = "myParameterA" });
    
    
    routes.MapRoute(
            "MyRoute2", // Route name
            "{controller}/{action}/{something}/{name}/{id}/secondroute/{myParameterB}", 
            new { controller = "MyController", action = "MyActionB", category = "something", name = "name", id = "id", myParameterB = UrlParameter.Optional } );
    

    See if that works.

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

Sidebar

Related Questions

I have just upgraded my project from ASP.net MVC 4 RC to RTM, but
I want to use ASP.NET Application Services but configure it to use a different
I have an ASP.NET MVC 3 website that communicates with my iOS app via
I have a lot of content-heavy views in my ASP.NET MVC 2 site. These
I have a legacy ASP.NET application in which there are some session/concurrency related issues
I am altering the question now! I have the search working using the following:
I have an ASP.NET page with a Wizard control containing several pages of form
Scenario Web server running an ASP.NET site that's connected to a sql server instance
I'm trying to send an email via some C# ASP.NET code. This is being
I have no intention of just altering the link (I hear that's impossible, but

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.