AmbiguousMatchException using MapAreaRoute with ASP.NET Core 2.2 · Issue #7772 · dotnet/aspnetcore (original) (raw)
Using the following routes:
app.UseMvc(routes =>
{
routes.MapAreaRoute(
name: "MyAreaProducts",
areaName:"Products",
template: "Products/{controller=Home}/{action=Index}/{id?}"
);
routes.MapAreaRoute(
name: "MyAreaServices",
areaName: "Services",
template: "Services/{controller=Home}/{action=Index}/{id?}"
);
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
Navigation to https://localhost:5001/Products/Home/About
throws:
An unhandled exception occurred while processing the request.
AmbiguousMatchException: The request matched multiple endpoints. Matches:
MVCareas.Areas.Products.Controllers.HomeController.About (MVCareas)
MVCareas.Controllers.HomeController.About (MVCareas)
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateSet candidates)
Repo here: Run app and select the Products/Home/About link.
Work around is to disable endpoint routing:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(options =>
options.EnableEndpointRouting = false)
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
Using .NET Core 2.2.2
cc @JamesNK