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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:00:41+00:00 2026-05-26T23:00:41+00:00

I have a route routes.MapRoute( AlphaPagedContacts, // Route name Contact/Alpha{alpha}, // URL with parameters

  • 0

I have a route

routes.MapRoute(
                "AlphaPagedContacts", // Route name
                "Contact/Alpha{alpha}", // URL with parameters
                new { controller = "Contact", action = "AlphaList", alpha = UrlParameter.Optional },
                new { alpha = @"\A-Z" } // Parameter defaults
            );

I’m trying to make the URL’s display like

/Contact/AlphaA
/Contact/AlphaB

for contacts based on username. However, the URL’s are showing up as: http://localhost:54568/Contact/AlphaList?alpha=H

My HTMLHelper is

@Html.AlphaLinks(new PagingModel { MaxPages = Model.MaxPages, CurrentLetter = Model.CurrentLetter, UrlGeneratorFunctionAlpha = i => Url.Action("AlphaList", new { alpha = i }) })

and my implementation is

    public static MvcHtmlString AlphaLinks(this HtmlHelper helper, PagingModel model)
    {
        string[] letters = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
        var stringBuilder = new StringBuilder("<ul class='pager'>");

        foreach (string letter in letters)
        {
            stringBuilder.Append(String.Format("<li {2}><a href='{1}'>{0}<a></li>", letter, model.UrlGeneratorFunctionAlpha(letter), letter == model.CurrentLetter ? "class=Selected" : String.Empty));
        }
        stringBuilder.Append("</ul>");
        return MvcHtmlString.Create(stringBuilder.ToString());
    }

My controller code for the actionresult is:

public ActionResult AlphaList(string alpha = "A")
    {
        var logic = new ContactBUS();
        var pageSize = 10;

        var usernames = from c in XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Contacts.xml")).Elements("Contact")
                        select new
                        {
                            Username = (string)c.Element("Username"),
                            Lastname = (string)c.Element("LastName"),
                            Firstname = (string)c.Element("FirstName"),
                            Email = (string)c.Element("Email"),
                        };

        var model = new AlphaListContactViewModel
        {
            Contacts = logic.GetContacts().Skip(0).Take(20).ToList(),
            CurrentLetter = alpha,
            MaxPages = (int)Math.Ceiling(logic.GetContactsCount() / (double)pageSize)
        };
        return View(model);
    }

Any idea why this is happening?
Also, I need to make it so that when the user clicks on a letter, it shows the contacts’ usernames for that letter.
Any help would be greatly appreciated.

  • 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-26T23:00:42+00:00Added an answer on May 26, 2026 at 11:00 pm

    Do you have any other routes that come before the one we see here? The first route that matches wins.

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

Sidebar

Related Questions

I have this route routes.MapRoute( ViewGames, // Route name psp/{controller}/{action}, // URL with parameters
I have a route: routes.MapRoute( Company, {id}/{name}.aspx, new { controller = Company, action =
I have the following route: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL with
I have the following route: routes.MapRoute( Default, // Route name {language}/{controller}/{action}/{id}, new { language
I have a route like routes.MapRoute( Reports, // Route name. reports/{controller}/{action}/{id}/{start}/{end}, // URL with
I have the following route defined: routes.MapRoute(name: StateResults, url: {state}/{searchTerm}, defaults: new { controller
I have the following route routes.MapRoute(CreateBook, {controller}/{action}/{slug}/{name}, new { controller = CreateBook, action =
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
route : routes.MapRoute(Default, {controller}/{action}/{id}/{args1}/{args2}/{args3}, // URL with parameters new { controller = Home, action
I have a route: routes.MapRoute(ResetPasswordConfirm, reset-password-confirm, new { controller = Membership, action = ResetPasswordConfirm

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.