Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Routes with similar query string params are not distinguished correctly #4880

@darrensteadman

Description

@darrensteadman

I have the following two URLs that I am trying to convert over from Web API 2 to MVC6

api/values/123?page=1&pageSize=10
api/values/123?from=2016-06-01T00:00:00&to=2016-06-02T00:00:00&page=1&pageSize=10

I have the following route attributes set

[Route("values/{id}/{page:int?}/{pageSize:int?}")]
[Route("values/{id}/{from?}/{to?}/{page:int?}/{pageSize:int?}")]

The issue is the two URLs always end up resolving to the same route. It would appear that I can no longer specify a unique route using the query string parameters as I used to be able to do. Also if I remove the optionals from the query string the handlers don't get hit at all.

I have also tried setting the Order value on the Route attribute and all that does is send both requests to whichever route has the priority.

If I change my URLs to

api/values/123/1/10
api/values/123/2016-06-01T00:00:00/2016-06-02T00:00:00/1/10

Then everything works fine, so it would appear that it's only a problem if query strings are being used. The issue I have is this is an API for an existing product that people have developed against and they will be using the query string URL format.

I am using the official RC2 release for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions