I would like to parse a string such as p1=6&p2=7&p3=8 into a NameValueCollection.
p1=6&p2=7&p3=8
NameValueCollection
What is the most elegant way of doing this when you don't have access to the Page.Request object?
Page.Request
There's a built-in .NET utility for this: HttpUtility.ParseQueryString
// C# NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);
' VB.NET Dim qscoll As NameValueCollection = HttpUtility.ParseQueryString(querystring)
You may need to replace querystring with new Uri(fullUrl).Query.
querystring
new Uri(fullUrl).Query
2.1m questions
2.1m answers
60 comments
57.0k users