I'm porting a legacy application to ASP.NET Core and I'm trying to keep the URLs consistent. Ideally I need to include a "file extension" in the URL, e.g. /Home/Index.ext should route to the Index action on HomeController.
I've started with the standard web application template in Visual Studio and tried modifying the default route:
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}.ext/{id?}");
A request for /Home/Index.ext then gives the error:
An unhandled exception occurred while processing the request.
AmbiguousMatchException: The request matched multiple endpoints. Matches:
WebApplication1.Controllers.HomeController.Index (WebApplication1)
WebApplication1.Controllers.HomeController.Privacy (WebApplication1)
WebApplication1.Controllers.HomeController.Error (WebApplication1)
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState)
I can't see why it's not taking the action name from this URL to select the correct action. Is there some way I can change this route pattern to get it to match this correctly?