public partial class RouteProvider : BaseRouteProvider, IRouteProvider
{
public int Priority => 10;
public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
{
var lang = GetLanguageRoutePattern();
endpointRouteBuilder.MapControllerRoute(name: "Fits",
pattern: "{lang}/{controller=Fits}/{action=Index}/{id?}");
}
}
The controller:
public async Task<IActionResult> Index(int id) {}
This route works perfectly as www.foo.com/controller/?id=1
But anything else:
www.foo.com/controller/1
www.foo.com/controller/index/1
will hit the controller with an id == 0.
Controller loads, it loads the view, then rewrites the url to page-not-found and shows "page not found"
If in the debugger I manually change id from 0 to 1, the url still gets re-written to page-not-found but the plugin view loads as expected with the correct data.
It seems my issue is directly tied to Nop's id-less routing. Basically: How do I circumvent this in a plugin?