mccalltd / AttributeRouting

Define your routes using attributes on actions in ASP.NET MVC and Web API.
http://mccalltd.github.io/AttributeRouting/
MIT License
416 stars 89 forks source link

Optional query values do not generate proper urls #218

Closed Bitsonthefloor closed 11 years ago

Bitsonthefloor commented 11 years ago

This is technically a continuation of [#216]

The issue now is if a query value is optional, but a value is provided, the url will not generate because there is a default value of Optional but no token on the underlying route url matches it. It seems this issue is similar to the contraints issue with query parameters. I think default values for query parameters have to be treated like the contraints, and handled post processing for the underlying route code.

Ex:

GET("/admin/news/article/new?{categoryId:long?}")

Url.Route(new { action = "article", controller = "news" }) == /admin/news/article/new Url.Route(new { action = "article", controller = "news", categoryId = 12 }) == null the second one should equal /admin/news/article/new?categoryId=12

mccalltd commented 11 years ago

Thanks for following up with this. I am going to get it fixed today.

mccalltd commented 11 years ago

Fixed in v3.5.5. Thanks again for reporting.