Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

497
Views
500 Internal: Multiple actions were found that match the request

AJAX

 $.ajax({
                url: '../api/TechViews/SView',
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify({ Filter: JSON.stringify(eth.Data), Type: $('.productType.active').data('name'), Name: $('#txtView').val() }),
                global: false,
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                   alert('success');

                },
                error: function (xhrequest, ErrorText, thrownError) {
                   alert('Fail');
                }
            });

Controller

    [Route("SView")]
    [HttpPost]
    public string Post([FromBody]TechViewsModel value)
    {
        string result = string.Empty;
        return result;
    }

    [Route("DView")]
    [HttpPost]
    public string Post([FromBody]TechViewsModel value)
    {
        string result = string.Empty;
        return result;
    }

The namespace used for Route is AttributeRouting.Web.Mvc. On the AJAX call i get 2 errors as 500 (Internal Server Error)

  1. For TechViews
  2. For SView

and the response is "Message":"An error has occurred.","ExceptionMessage":"Multiple actions were found that match the request: \r\nSystem.String Post

RouteConfig

 public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Login", action = "LoginPage", id = UrlParameter.Optional }
        );
    }

I tried ,

  1. Removing HttpPost
  2. Re-Order HttpPost and Route
  3. Changing names for naming conntraints
  4. Removing FromBody in the param
  5. Changing the Method name and Parameter Type.

When i used only one post with no Route the same code works fine.

Where am i wrong?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Enable config.MapHttpAttributeRoutes() option in api routing configuration.

public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

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

In global.asax.cs

GlobalConfiguration.Configure(WebApiConfig.Register);
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!