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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:38:20+00:00 2026-06-12T11:38:20+00:00

I am starting to use MVC4 Web API project, I have controller with multiple

  • 0

I am starting to use MVC4 Web API project, I have controller with multiple HttpPost methods. The Controller looks like the following:

Controller

public class VTRoutingController : ApiController
{
    [HttpPost]
    public MyResult Route(MyRequestTemplate routingRequestTemplate)
    {
        return null;
    }

    [HttpPost]
    public MyResult TSPRoute(MyRequestTemplate routingRequestTemplate)
    {
        return null;
    }
}

Here MyRequestTemplate represents the template class responsible for handling the Json coming through the request.

Error:

When I make a request using Fiddler for http://localhost:52370/api/VTRouting/TSPRoute or http://localhost:52370/api/VTRouting/Route I get an error:

Multiple actions were found that match the request

If I remove one of the above method it works fine.

Global.asax

I have tried modifying the default routing table in global.asax, but I am still getting the error, I think I have problem in defining routes in global.asax. Here is what I am doing in global.asax.

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapHttpRoute(
        name: "MyTSPRoute",
        routeTemplate: "api/VTRouting/TSPRoute",
        defaults: new { }
    );

    routes.MapHttpRoute(
        name: "MyRoute",
        routeTemplate: "api/VTRouting/Route",
        defaults: new { action="Route" }
    );
}

I am making the request in Fiddler using POST, passing json in RequestBody for MyRequestTemplate.

  • 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-12T11:38:22+00:00Added an answer on June 12, 2026 at 11:38 am

    You can have multiple actions in a single controller.

    For that you have to do the following two things.

    • First decorate actions with ActionName attribute like

       [ActionName("route")]
       public class VTRoutingController : ApiController
       {
         [ActionName("route")]
         public MyResult PostRoute(MyRequestTemplate routingRequestTemplate)
         {
           return null;
         }
      
        [ActionName("tspRoute")]
        public MyResult PostTSPRoute(MyRequestTemplate routingRequestTemplate)
        {
           return null;
        }
      }
      
    • Second define the following routes in WebApiConfig file.

      // Controller Only
      // To handle routes like `/api/VTRouting`
      config.Routes.MapHttpRoute(
          name: "ControllerOnly",
          routeTemplate: "api/{controller}"               
      );
      
      
      // Controller with ID
      // To handle routes like `/api/VTRouting/1`
      config.Routes.MapHttpRoute(
          name: "ControllerAndId",
          routeTemplate: "api/{controller}/{id}",
          defaults: null,
          constraints: new { id = @"^\d+$" } // Only integers 
      );
      
      // Controllers with Actions
      // To handle routes like `/api/VTRouting/route`
      config.Routes.MapHttpRoute(
          name: "ControllerAndAction",
          routeTemplate: "api/{controller}/{action}"
      );
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting a new project using MVC4 and would like to use dependency
Just starting to use Ruby on Rails to see what its like. I have
I'm starting to use GameKit for a p2p project, and I want to call
I am just starting to use Wix and would like to use heat to
I'm starting to use Role Management in my website, and I'm currently following this
I'm starting to use facebook graph api to create events with javascript! It works
I´m starting to use jenkins and I have problems with the authentication when I
I'm starting to use Apache buildr. As far as I understand, I always have
I'm starting to use webservices in Android and I followed this tutorial: Create Web
I am just starting to use RabbitMQ and AMQP in general. I have a

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.