Skip to content

Ambiguous match routes #62

Open
Open
@JohanLarsson

Description

@JohanLarsson
namespace AspBox
{
    using System.Collections.Generic;
    using Microsoft.AspNetCore.Mvc;

    [Route("api/values")]
    [Route("api/values/{id}")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET api/values
        [HttpGet]
        public ActionResult<IEnumerable<string>> Get()
        {
            return new string[] { "value1", "value2" };
        }

        [HttpGet]
        public ActionResult<string> Get(int id)
        {
            return $"'{id}'";
        }
    }
}
AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:
 
 AspBox.ValuesController.Get (AspBox)
 AspBox.ValuesController.Get (AspBox)
Microsoft.AspNetCore.Mvc.Internal.ActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList<ActionDescriptor> candidates)
Microsoft.AspNetCore.Mvc.Internal.MvcAttributeRouteHandler.RouteAsync(RouteContext context)
Microsoft.AspNetCore.Routing.Tree.TreeRouter.RouteAsync(RouteContext context)
Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context)
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions