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

  • SEARCH
  • Home
  • 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 8316781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:26:11+00:00 2026-06-08T21:26:11+00:00

When trying to find solution for this below question: MVC Web Api Route with

  • 0

When trying to find solution for this below question:

MVC Web Api Route with default action not working

Mostly I run across the problem “multiple actions were found”. If routing mechanism finds out more than one actions matched with a route, it throws out the exception 500.

For example, there are two actions in ValuesController:

[HttpGet]
public IEnumerable<String> Active()
{
    var result = new List<string> { "active1", "active2" };
    return result;
}

public IEnumerable<string> Get()
{
    return new[] { "value1", "value2" };
}

which match with default route:

 routes.MapHttpRoute(
          name: "DefaultApi",
          routeTemplate: "api/{controller}/{id}",
          defaults: new { id = RouteParameter.Optional }
      );

With

GET: /api/values 

will get error multiple actions were found.

My question: how I can bypass the exception “multiple actions were found” by choosing specified action (choose the first matched action is also okay).

Update 1: Update from tugberk’s comment, thanks to point out.

Update 2: Update from Mike’s comment, seems the question is not correct much, so I change the way to ask by not mentioning the routing constraint.

Thanks

  • 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-08T21:26:12+00:00Added an answer on June 8, 2026 at 9:26 pm

    First of all, it shouldn’t be possible for those route to match Active action unless you apply HttpGet attribute on it. I will assume you already did that. The second thing is that what you want is not logical. You would like to make a get request and have two identical actions. You are now using so-called HTTP-method-based routing. For you situation, I am sure that so-called action-based routing is the best.

    Assuming you have following two actions:

    [HttpGet]
    public IEnumerable<String> Active()
    {
        var result = new List<string> { "active1", "active2" };
        return result;
    }
    
    [HttpGet]
    public IEnumerable<string> Retrieve()
    {
        return new[] { "value1", "value2" };
    }
    

    You route should be as follows:

    routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    

    Then you can request to those with following URIs:

    GET /controllername/retrieve

    GET /controllername/active

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

Sidebar

Related Questions

I have been trying to find a solution to this one but could not
I've spent the last few hours trying to find the solution to this question
I have searched around Google and StackOverflow trying to find a solution to this,
I'm having troubles trying to find a solution, if any, to this: public class
I was trying to find a solution but did not succeed even if it
I've been trying all night to find a solution to this problem and haven't
I am trying to find a solution to prevent race conditions in my application
I'm trying to find a solution to add HTTP digest auth to a site
I am trying to find a solution that will resolve a recurring deadlock situation
I'm trying to find a solution for pinpointing indoors, specifically inside big crowded places,

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.