Skip to content

HttpUtility.ParseQueryString doesn't roundtrip when there are multiple values for the same key, behavior is inconsistent with .NET Framework #27518

Closed

Description

@thomaslevesque

In .NET Framework the HttpUtility.ParseQueryString has roundtripping behavior, i.e. the following test passes:

        [Fact]
        public void ParseQueryString_and_ToString_should_roundtrip_when_multiple_values_for_the_same_key()
        {
            var input = "type=foo&type=bar";
            var values = HttpUtility.ParseQueryString(input);
            var output = values.ToString();
            Assert.Equal(input, output);
        }

However, in .NET Core (2.1), this test fails: values.ToString() returns type=foo%2cbar.

Activity

  1. thomaslevesque commented on Oct 2, 2018

    @thomaslevesque
    MemberAuthor

    The issue still exists in 2.2 preview

  2. karelz commented on Oct 2, 2018

    @karelz
    Member

    Confirmed that it fails on .NET Core 2.0 (when it was introduced). On .NET Framework (4.7.2) the result is correct.

    After a bit debugging it seems to be difference in implementations:

    This should be fairly simple to fix. Anyone interested?

  3. davidsh commented on Oct 2, 2018

    @davidsh
    Contributor

    There is already a PR for this submitted: dotnet/corefx#32578

  4. karelz commented on Oct 2, 2018

    @karelz
    Member

    Darn, I missed that :(

  5. thomaslevesque commented on Oct 3, 2018

    @thomaslevesque
    MemberAuthor

    As mentioned by @karelz in dotnet/corefx#32578 (comment), there's another case that is handled by .NET Framework but not by .NET Core: keys without values, i.e. name&another. This should probably be a separate issue, though.

  6. thomaslevesque commented on Oct 3, 2018

    @thomaslevesque
    MemberAuthor

    As mentioned by @karelz in #32578 (comment), there's another case that is handled by .NET Framework but not by .NET Core: keys without values, i.e. name&another. This should probably be a separate issue, though.

    Opened https://github.com/dotnet/corefx/issues/32598 to take care of this.

  7. transferred this issue fromdotnet/corefxon Jan 31, 2020
  8. added this to the 3.0 milestone on Jan 31, 2020
  9. ghost locked as resolved and limited conversation to collaborators on Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-System.Netbugtenet-compatibility

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions