Skip to content

AmbiguousActionException after upgrade from 1.0-beta 2 to 1.0-rc1 (and all later versions) (ASP.Net Core) #147

Closed
@Eneuman

Description

@Eneuman

Hi!

I think 1.0 rc1 introduced a bug when using route attributes in web api with Asp.Net Core 1.1.2
The following code works fine in mvc.versioning beta2.

[ApiVersion("1.0")]
[Route("[controller]")]
[Produces("application/json")]
public class ErsattningsunderlagController : Controller
......

[HttpGet("{id}"), MapToApiVersion("1.0")]
public async Task<IActionResult> HämtaErsättningsunderlagAsyncV1([FromRoute]int id)
{
....
}

[HttpGet("Pagaende"), MapToApiVersion("1.0")]
public async Task<IActionResult> HämtaPågåendeErsättningsunderlagFörGridAsyncV1()
{
.....
}

But the exact same code fails to run after upgrade (I only added app.UseApiVersioning() to startup);

The error is this:

Microsoft.AspNetCore.Mvc.Internal.AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:

Ekonomi.Forsaljning.Service.Controllers.ErsattningsunderlagController.HämtaPågåendeErsättningsunderlagFörGridAsyncV1 (Ekonomi.Forsaljning.Service)
Ekonomi.Forsaljning.Service.Controllers.ErsattningsunderlagController.HämtaErsättningsunderlagAsyncV1 (Ekonomi.Forsaljning.Service)
   vid Microsoft.AspNetCore.Mvc.Routing.DefaultApiVersionRoutePolicy.OnMultipleMatches(RouteContext context, ActionSelectionResult selectionResult)
   vid Microsoft.AspNetCore.Mvc.Routing.DefaultApiVersionRoutePolicy.RouteAsync(RouteContext context)
   vid Microsoft.AspNetCore.Routing.RouteCollection.<RouteAsync>d__9.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()

It seems like something is breaking routing.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions