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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:43:54+00:00 2026-05-13T19:43:54+00:00

Asking for the best way to address this issue: in my controller I have

  • 0

Asking for the best way to address this issue:

in my controller I have the following action

public ActionResult Member(string id){return View();}

another action in the same controller

public ActionResult Archive(string year){return View();}

in my global.asax

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

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

if I call this url mysite.com/archive/2009 this works because the action expecting parameter with a name “year” and the first route schema works with this request. But if I call this url mysite.com/member/john it will result in this url mysite.com/member?id=john
So it looks like if my first route in global.asax have the same construction but different parameter name, the one with the right parameter name will have the right url (mysite.com/archive/2009) but for the other won’t. How can I solve this issue? I can change the route table to expect a generic parameter name like “param”, but I need to change all the signature of the action to “param” as well and it is not very descriptive (param instead year or param instead id).

  • 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-13T19:43:54+00:00Added an answer on May 13, 2026 at 7:43 pm

    Try this:

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

    You are allowed to use literals in the second parameter, and they will act as filters. The more specific your route is, the closer you need to put it to the top of the route configuration, the routing system will choose the first route that matches.

    Here is a link to more detailed background information. Some of the syntax has changed since the article was written but the basic rules seem up to date.

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

Sidebar

Related Questions

Basically, I'm asking for the best way to do the following: I have a
I may not be asking this in the best way possible but i will
http://img683.imageshack.us/img683/645/weatherscreenmockupoutl.png I am asking myself whats the best way to code this layout. Basicly
This is just a curious question. Which one is the best way to update
I had an interview question asking this: text file has following lines> 1: A
I have been perusing the internet in search of the best way to accomplish
Could someone explain the best way to achieve the following, I think it's a
Duplicate: Best way to obfuscate an e-mail address on a website? Effective method to
I have been looking at a lot of these questions asking for the best
What is the best way to search in xml? Xpath or Linq2xml. I'm asking

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.