Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes and optional nullable parameters #483

Closed
RobertVejvoda opened this issue Oct 23, 2017 · 0 comments
Closed

Routes and optional nullable parameters #483

RobertVejvoda opened this issue Oct 23, 2017 · 0 comments
Labels
Milestone

Comments

@RobertVejvoda
Copy link
Contributor

My route is defined as:

dotvvmConfiguration.RouteTable.Add("Test, "Test/{parentId}/{childId?}", "Views/test.dothtml");

The childId is an optional parameter.

Method call to route.BuildUrl(new {parentId, childId} throws exception.

The issue is likely in DotvvmRoute.cs, method ParseParameter()

if (v.TryGetValue(name, out obj))
    return prefix + obj.ToString();
return "";

--> obj is null

The workaround is not to set parameters having null values at all, but it's not ideal.

var url = childId.HasValue ? route.BuildUrl(new {parentId, childId}) : route.BuildUrl(new { parentId });
@djanosik djanosik added this to the Version 1.1.7 milestone Oct 23, 2017
@djanosik djanosik added the bug label Oct 23, 2017
@exyi exyi closed this as completed in 27efe21 Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants