// Create a query
...
var queryString = HttpUtility.ParseQueryString(string.Empty);
queryString["q"] = userQuery;
var query = "https://api.bing.microsoft.com/v7.0/search?" + queryString;
...
the code is depending on an implementation of ToString() in a private class HttpQSCollection, which is never descripted in any documents. NameValueCollection was never guaranteed returning a query string liked string.
By the context, the code can be easily replaced by
var query =$"https://api.bing.microsoft.com/v7.0/search?q={userQuery}";
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
ID: 07544180-360e-4ca4-c769-9e9f75c41fdb
Version Independent ID: 6d976c50-c629-a5fa-5892-263a54b08d3a
In the document:
the code is depending on an implementation of
ToString()
in a private classHttpQSCollection
, which is never descripted in any documents.NameValueCollection
was never guaranteed returning a query string liked string. By the context, the code can be easily replaced byDocument Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.