dotnet / dotnet/dotnet-api-docs

HttpUtility.ParseQueryString ambiguous return type. Should be HttpValueCollection instead of NameValueCollection.

Open
#10,876 1 comment 0 reactions 0 assignees View on GitHub
area-System.Collections untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Other (describe below)

### Description

The HttpUtility.ParseQueryString(...) states that the return value is NameValueCollection while in fact it returns HttpValueCollection.

HttpValueCollection derives from NameValueCollection and techincally 'is' NameValueCollection,
The HttpValueCollection.ToString() implementation is quite different form the one in NameValueCollection.
The HttpUtility.ParseQueryString(...) documentation implies one can create new NameValueCollection() instead of calling the method, and it will behave the same way.

E.g. based on the documentation the code blow should produce the same result.
var query = HttpUtility.ParseQueryString("");
query["message"] = message;
query.ToString();

var query = new NameValueCollection();
query["message"] = message;
query.ToString();

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.web.httputility.parsequerystring?view=net-9.0

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Web/HttpUtility.xml

### Document Version Independent Id

cab0e9f7-1984-a4d4-bbdc-ec6a45ef1159

### Article author

@Rick-Anderson

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.