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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:06:26+00:00 2026-05-23T00:06:26+00:00

I’ve got the following code (from a partial view), which creates a list of

  • 0

I’ve got the following code (from a partial view), which creates a list of links enabling me to filter the items listed within my index page according to the letter they begin with:

@{
    string letters = "abcdefghijklmnopqrstuvwxyz";
}
<ul>
    <li>@Html.ActionLink("0–9", "Index")</li>
    @foreach (char c in letters.ToCharArray()) {
        <li>@Html.ActionLink(c.ToString().ToUpper(), "Index", new { letter = c.ToString() })</li>
    }
</ul>

The first link in the list is for cases where the items begin with a number. I’ve also got the following routes set up in my Global.asax file:

routes.MapRoute(
    "",
    "artists",
    new { controller = "Artist", action = "Index" }
);

routes.MapRoute(
    "",
    "artists/{letter}",
    new { controller = "Artist", action = "Index" },
    new { letter = "[a-z]" }
);

So the paths for the links that the above partial view creates should look something like:

/artists
/artists/a
/artists/b
…

and so on. What I’m getting though is odd in that it’s ignoring the routing and creating links like:

/artists
/artists?letter=a
/artists?letter=b
…

Now, if I swap around the order of the routes, it produces the links as I want them, but then I run into another problem. If I then navigate to /artists/a (or any other letter), the first link in the list picks up the current value of the letter parameter and appends it to the list, so I end up with links like:

/artists/a
/artists/a
/artists/b
…

As you can see, that makes it impossible to get back to the index with no filtering. Any ideas as to how I can either fix the routing so that the links are created correctly without the parameters being passed as a query string, or fix the ActionLink as to not append the current parameter?

  • 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-23T00:06:27+00:00Added an answer on May 23, 2026 at 12:06 am

    Make only one route and set the {letter} parameter as optional.

    routes.MapRoute(
        "artists",
        "artists/{letter}",
        new { controller = "Artist", action = "Index", letter = UrlParameter.Optional },
        new { letter = "[a-z]" }
    );
    

    EDIT:

    Have a look at this post.

    EDIT2:

    Another possible solution would be:

    routes.MapRoute(
        "artists",
        "artists/{letter}",
        new { controller = "Artist", action = "Index", letter = "0" },
        new { letter = "[0a-z]" }
    );
    
    @Html.ActionLink("0–9", "Index", new { letter = "0"} );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the following code from here to read an Excel file using
I tried the following code in LINQPad and got the results given below: List<string>
In my app I've got certain buttons which use the following code: SystemSoundID beep;
I've got the following code from php.net: $GLOBALS['normalizeChars'] = array( 'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z',
I've got the following code to end a process, but I still receive an
Let's assume we've got the following Java code: public class Maintainer { private Map<Enum,
I've got the following piece of code in an aspx webpage: Response.Redirect(/Someurl/); I also
I've got the following bit of code (that another developer wrote) that I need
I've got the a SQL Server stored procedure with the following T-SQL code contained
I've got code similar to the following... <p><label>Do you have buffet facilities?</label> <asp:RadioButtonList ID=blnBuffetMealFacilities:chk

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.