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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:46:06+00:00 2026-05-16T16:46:06+00:00

I am struggling with generating outbound urls in asp.net mvc 2. Here is the

  • 0

I am struggling with generating outbound urls in asp.net mvc 2. Here is the scenario.

Controller: MoveController
Action: Index()
View: Index.aspx

Now what I would like is to have multiple urls mapping to same controller (MoveController) and action (Index) with different parameter (locationId) value

e.g.

  • url -> RouteData
  • /Production/ -> Move/Index/1
  • /Installation/ -> Move/Index/2
  • /Move/3/ -> Move/Index/3

My mapping look like this:

 public static void RegisterRoutesTo(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{*favicon}", new
        {
            favicon = @"(.*/)?favicon.ico(/.*)?"
        });

        routes.MapRoute(
           null,                                              // Route name
           "Production/{locationId}",                           // URL with parameters
           new
           {
               controller = "Move",
               action = "Index"
           },  // Parameter defaults
           new
           {
               locationId = @"\d+"
           }// constraint for Production url
       );

        routes.MapRoute(
           null,                                              // Route name
           "Installation/{locationId}",                           // URL with parameters
           new
           {
               controller = "Move",
               action = "Index"
           },  // Parameter defaults
           new
           {
               locationId = @"\d+"
           }// constraint for Production url
       );

        routes.MapRoute(
           null,                                              // Route name
           "Move/{locationId}",                           // URL with parameters
           new
           {
               controller = "Move",
               action = "Index"
           },  // Parameter defaults
           new
           {
               locationId = @"\d+"
           }// constraint for Production url
       );

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

Now to generate the outbound urls in my master page menu, I am doing something lik ethis

<%= Html.ActionLink("Production", "Index", "Move", new{locationId = 1}, null)%>
<%= Html.ActionLink("Installation", "Index", "Move", new{locationId = 2}, null)%>

But the above generates

  • /Production/1
  • /Production/2

which is correct, but how can i tell it to generate

  • /Production/ when the locationId =1
  • /Installation/ when locationId = 2

Any Idea?

Awaiting,

  • 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-16T16:46:07+00:00Added an answer on May 16, 2026 at 4:46 pm

    long shot, but definitely worth a shot as your routes above weren’t expressing what you want:

    routes.MapRoute(
       null,                                              // Route name
       "Production/",                           // URL with parameters
       new
       {
           controller = "Move",
           action = "Index",
           locationId = 1
       }
    

    );

    routes.MapRoute(
       null,                                              // Route name
       "Installation/",                           // URL with parameters
       new
       {
           controller = "Move",
           action = "Index",
           locationId = 2
       }
    

    );

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

Sidebar

Related Questions

I'm struggling with line break in UILabel. I'm generating xml in vb.net and then
im struggling with syntax here: hopefully this question is v simple, im just miising
Struggling with a SQL query of mine here. I have a table: APPS(id, game)
ok i have bin struggling with this for quiet long nw...i am generating iframes
I'm struggling to create a dynamic view generation utility for javafx. I've a handful
I'm struggling with onbeforeunload, onunload and generating the right messages at the right time.
I've implemented a variant of the very cunning answer here for generating unique IDs
Struggling with the basics here. I want to setup an array, and fill it
I have a PHP script which I am trying to convert to ASP.NET C#
Struggling here, I'm Using .draggable on a div which works fine but I also

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.