dotvvm icon indicating copy to clipboard operation
dotvvm copied to clipboard

Invalid route generation with multiple parameters

Open ridercz opened this issue 8 years ago • 7 comments

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/.

ridercz avatar Feb 14 '17 17:02 ridercz

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.

exyi avatar Feb 15 '17 11:02 exyi

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.

tomasherceg avatar Feb 15 '17 11:02 tomasherceg

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.

exyi avatar Feb 15 '17 16:02 exyi

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.

tomasherceg avatar Jul 24 '17 11:07 tomasherceg

@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?

tomasherceg avatar Jan 21 '21 09:01 tomasherceg

No, i have not added a step to remove double slashes

exyi avatar Jan 21 '21 09:01 exyi

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.

tomasherceg avatar Jul 20 '21 10:07 tomasherceg