dotvvm
dotvvm copied to clipboard
Invalid route generation with multiple parameters
My route is defined as follows:
config.RouteTable.Add("Calendar",
"kalendar/{Year:posint}/{Month:posint}",
"Views/Calendar.dothtml",
new { Year = 0, Month = 0 });
I'm calling it from RouteLink control:
<dot:RouteLink RouteName="Calendar" Param-Month="" Param-Year="">...</dot:RouteLink>
The resulting URL is /kalendar//
instead of just /kalendar/
.
It seems to be correct behavior - you are passing an empty string to the parameter. Maybe we could just validate the parameter for posint
constraint.
I think we should replace sequences of multiple slashed with just one slash in the URL and make sure that it will match the route correctly. This should work the same as in MVC, so we should do a research how this thing works there and then adjust the behavior to be the same in DotVVM.
Removing double slash would not help: /kalendar//
- Year is not integer, /kalendar/
- argument is missing.
I have just tried what MVC does and it says that no matching route was found, when the values are empty. If the route parameters would be optional, MVC returns /kalendar
.
We need someone to do a research of these situations and compare how MVC and DotVVM behaves. After we have the table of differences, we should decide how to adjust the mechanism.
@exyi You were fixing something in the RouteLink
control and if I remember correctly, you discovered some issues related to this - is this issue still relevant?
No, i have not added a step to remove double slashes
We've discussed this and we can validate the parameter constraints when generating the link (when the page is compiled), and maybe generate warnings when the parameter is data-bound.