MapDynamicControllerRoute doesn't consider ActionMethodSelectorAttribute
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
The following code will produce an exception:
AmbiguousMatchException: The request matched multiple endpoints.
- App.Web.Controllers.TestController.ButtonClick1 (App.Web)
- App.Web.Controllers.TestController.ButtonClick2 (App.Web)
```
public class FormConstraintAttribute : ActionMethodSelectorAttribute
{
...
}
public async Task Form()
{
return View();
}
[HttpPost, ActionName(nameof(Form), FormConstraint("button", "1")]
public async Task ButtonClick1()
{
return View(nameof(Form));
}
[HttpPost, ActionName(nameof(Form), FormConstraint("button", "2")]
public async Task ButtonClick2()
{
return View(nameof(Form));
}
```
Setup:
```
// This will throw AmbiguousMatchException:
routeBuilder.MapDynamicControllerRoute("{**path}");
// This works:
routeBuilder.MapControllerRoute(routeName: "Form", pattern: "form", defaults: new { controller = "Test", action = "Form" });
```
With the "old" IRouter this was possible.
Contributor guide
Assessment
This issue has not been assessed yet.