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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:13:28+00:00 2026-05-18T20:13:28+00:00

I changed the default routing in ASP.NET MVC from routes.MapRoute( Default, // Route name

  • 0

I changed the default routing in ASP.NET MVC from

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

to

        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}/{lineNo}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional, lineNo = UrlParameter.Optional });

but now all @Html.ActionLink() calls are rendered to href=””. If I change the route back to default all links are working again.

I used the same route with RC1 and it worked perfectly.

I didn’t find anything in the release docs so I think I’m doing it wrong.

Regards,
Steffen

  • 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-18T20:13:29+00:00Added an answer on May 18, 2026 at 8:13 pm

    In a route an optional parameter can appear only at the end. This means that in your route definition the id parameter cannot be optional. You need to explicitly set it to a value.

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}/{lineNo}",
        new { 
            controller = "Home", 
            action = "Index", 
            lineNo = UrlParameter.Optional 
        }
    );
    

    And when you generate a link you must always provide a value for the id parameter if you want this route to match:

    @Html.ActionLink("some link", "index", new { id = "123" })
    

    As an alternative you might give a default value to the id parameter:

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}/{lineNo}",
        new { 
            controller = "Home", 
            action = "Index", 
            id = "123",
            lineNo = UrlParameter.Optional 
        }
    );
    

    Now you no longer need to specify it in your links.

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

Sidebar

Related Questions

I changed the default routing in ASP.NET MVC from routes.MapRoute( Default, // Route name
With ASP MVC the routing works with the following code routes.MapRoute(Default, {controller}/{action}/{id}, new {
I am trying to implement Url routing in asp.net 4.0. I just a created
By default the resources command generates the url for new action as {model}/new .
We have a classic VBScript default.asp page in the root of our site. (This
I am having a problem getting a MVC 3 project running in IIS7 on
I have 2 namespaces for my controllers. One is the default MyProject.Controllers and the
I am working in cakephp, and I have the following two lines in my
You may have a bytea column mapped as Hibernate type binary. In java, the
I'm attempting to use Jammit for packaging CSS and JS for a Rails app

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.