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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:56:40+00:00 2026-06-05T21:56:40+00:00

I am having problems with my MVC Routes. I am trying to get to

  • 0

I am having problems with my MVC Routes.

I am trying to get to the following url … “http://localhost/api/Countries“

I have defined the following routes in the following order …

    RouteTable.Routes.MapHttpRoute(
        name: "Continents",
        routeTemplate: "api/countries/Continents",
        defaults: new { controller = "countries", Action="Continents" }
        );
    RouteTable.Routes.MapHttpRoute(
        name: "CountryRegions",
        routeTemplate: "api/countries/Regions",
        defaults: new { controller = "countries", Action = "CountryRegions" }
        );

    RouteTable.Routes.MapHttpRoute(
        name: "CountryByCodeApi",
        routeTemplate: "api/{controller}/{countryCode}",
        defaults: new { controller="countries", countryCode = System.Web.Http.RouteParameter.Optional }
        );

Whenever I go to the desired URL I am getting the error “Multiple actions were found that match the request“. This would make sense if the third segment of the routeTemplate property was optional but it was my understanding that by NOT enclosing it in braces that it made it a required segment in the target URL. Obviously “http://localhost/api/countries” does not include “Continents” or “Regions” so why would they be identified as matching the request.

Ya’ know. These routes SEEM like a simple enough thing but when you get down to it it’s a cryptic as RegEx’s !!!

Any thoughts?

  • 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-05T21:56:43+00:00Added an answer on June 5, 2026 at 9:56 pm

    The last route definition doesn’t provide action name through route definition nor it provides it through route defaults. If route definition should omit it, then add it to defaults as this:

    routes.MapRoute(
        "CountryByCodeApi",
        "api/{controller}/{countryCode}",
        new {
            controller="countries",
            countryCode = RouteParameter.Optional,
            action = "CountryCodes"
        }
    );
    

    Note that this is just the last route definition. The upper couple stays as it is.

    public ActionResult CountryCodes(string countryCode)
    {
        // do whatever you please
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems creating MVC 3 T4 template. I have cleared the Custom Tool
I'm having problems when trying to change the model of my view in MVC
I am having problems trying to get a very simple ASP.Net application to start
I'm having a problem trying to get routing to work with ASP.NET MVC 3.0.
I'm using MVC 4 (beta), and having some problems trying to test an auth
I'm having problems publishing my MVC project. When I do publish and upload everything
I am using MVC-View Model, EF Model first I am having problems with two
Having problems with a small awk script, Im trying to choose the newest of
I'm having problems with setting validations date format Chrome in asp.net mvc, for other
I'm having problems running MVC2. I've compiled defult MVC project and deployed it on

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.