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

  • Home
  • SEARCH
  • 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 178681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:16:25+00:00 2026-05-11T14:16:25+00:00

I am having trouble with Html.ActionLink when I have a route that takes more

  • 0

I am having trouble with Html.ActionLink when I have a route that takes more than one parameter. For example, given the following routes defined in my Global.asax file:

routes.MapRoute(     'Default',                                              // Route name     '{controller}.mvc/{action}/{id}',                           // URL with parameters     new { controller = 'Home', action = 'Index', id = '' }  // Parameter defaults );  routes.MapRoute(     'Tagging',     '{controller}.mvc/{action}/{tags}',     new { controller = 'Products', action = 'Index', tags = '' } );  routes.MapRoute(     'SlugsAfterId',     '{controller}.mvc/{action}/{id}/{slug}',     new { controller = 'Products', action = 'Browse', id = '', slug = '' } ); 

The first two routes work without a problem, but when I try to create an action link to the third route using:

<%= Html.ActionLink(Html.Encode(product.Name), 'Details', new { id = product.ProductId, slug = Html.Encode(product.Name) }) %> 

I end up with a URL like [site-root]/Details/1?slug=url-slug whereas I would like the URL to be more like [site-root]/Details/1/url-slug

Can anyone see where I am going wrong?

  • 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. 2026-05-11T14:16:25+00:00Added an answer on May 11, 2026 at 2:16 pm

    It is using the first route that is fully satisfied. Try putting your SlugsAfterId route above the Default one.

    It’s basically going: ‘Check Default. Got an action? Yes. Got an id? Yes. Use this one and chuck any other parameters in the querystring.’

    As a side note, doing that will make your Default route redundant as you provide a default value for the slug parameter.

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

Sidebar

Related Questions

I having trouble in dividing the HTML frames. I have been using the following
I'm having trouble converting an array into correctly nested HTML. Assuming I have an
Good morning, I am having trouble with the following code <html> <head> <title>highlight date</title>
After I upgraded to the beta, I'm having trouble with Html.RadioButtonList. Can someone show
I am using HTML Purifier in my PHP project and am having trouble getting
I am having trouble with IE7. I have a header, which is an IMG.
I'm having trouble with global variables in php. I have a $screen var set
I am using the jQuery qTip plugin and am having trouble loading html content
I'm having trouble with this piece of functionality I'm trying to have an accordion
I'm having trouble getting a td to have some text at its top and

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.