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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:30:30+00:00 2026-06-15T00:30:30+00:00

I know this has been asked before but I’m really struggling with the concept

  • 0

I know this has been asked before but I’m really struggling with the concept of route configs in MVC – specifically removing controller names and/or action names from a URL.

On my webpage, I have a partial view called “Sidebar”, which uses its own controller (SidebarController).

Within the sidebar’s partial view, I have the following ActionLink:

@Html.ActionLink("December-2012", "Archive", new { id = "December-2012" })

When the link is built, the URL reads as

http://localhost/Sidebar/Archive/December-2012

My problem is having the “Sidebar” part appearing in the URL – this controller isn’t technically used for any navigation; it’s just used to build the partial view. Instead, I want the URL to read:

http://localhost/Archive/December-2012

I tried specifying the controller on the ActionLink, but this just results in

http://localhost/Archive/Archive/December-2012

Could somebody please explain (in simpleton terms) how I configure a route so that when /Archive is put on the end of the URL, it knows to call the ArchiveController with (let’s say) the Index(id) action?

Thanks in advance, and apologies for asking a question that’s been covered before – as I said I’m just really struggling with the whole concept of route maps.

  • 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-06-15T00:30:31+00:00Added an answer on June 15, 2026 at 12:30 am

    Not entire sure what your doing wrong here. Perhaps also include the code for the second url.

    You could use this overload of the Html.ActionLink method:

    public static MvcHtmlString ActionLink(
        this HtmlHelper htmlHelper,
        string linkText,
        string actionName,
        string controllerName,
        Object routeValues,
        Object htmlAttributes
    )
    

    You would use it like this:

    @Html.ActionLink("December-2012(ThisIsLinkText)", "Index", "Archive", 
                     new { id = "December-2012"}, null);
    

    Which will produce the following url:

    http://localhost/Archive/Index/December-2012
    

    Update:

    Based on your comment you need this route above your default route:

    routes.MapRoute(
        "ArchiveRoute", 
        "Archive/{id}", 
        new { controller = "Archive", action = "Index", id = UrlParameter.Optional } 
    );
    

    And the same action link should map to this url:

    @Html.ActionLink("December-2012(ThisIsLinkText)", "Index", "Archive", 
                     new { id = "December-2012"}, null);
    

    Remember the route has to be above the Default route.

    This url should then work:

    http://localhost/Archive/December-2012
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this has been asked before but I really didn't know what to
I know this has been asked before but I'm struggling.. I barely know any
I know this has been asked before but there is really not a clear
I know this question has been asked before but I really couldn't find anything
I know this has been asked before but all the answers I found didn't
Ok, I know this has been asked before but after searching I couldn't find
I know this has probably been asked before but for my problem I cannot
I know this probably has been asked before but I am having issues with
I know this has been asked much the same before but no answers seem
I know this has been asked before, but I just cant seem to find

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.