UriTemplateMatch.QueryParameters Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of query string parameters and their values.
public:
property System::Collections::Specialized::NameValueCollection ^ QueryParameters { System::Collections::Specialized::NameValueCollection ^ get(); };
public System.Collections.Specialized.NameValueCollection QueryParameters { get; }
member this.QueryParameters : System.Collections.Specialized.NameValueCollection
Public ReadOnly Property QueryParameters As NameValueCollection
Property Value
A NameValueCollection instance that contains the query string parameters and their values.
Examples
The following code shows how to access the QueryParameters property.
UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast=today");
Uri baseAddress = new Uri("http://localhost");
Uri fullUri = new Uri("http://localhost/weather/WA/Seattle?forecast=today");
Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString());
// Match a URI to a template
UriTemplateMatch results = template.Match(baseAddress, fullUri);
if (results != null)
{
Console.WriteLine("QueryParameters:");
foreach (string queryName in results.QueryParameters.Keys)
{
Console.WriteLine(" {0} : {1}", queryName, results.QueryParameters[queryName]);
}
Console.WriteLine();
}
// Code output:
// QueryParameters:
// forecast : today
Dim template As New UriTemplate("weather/ state}/ city}?forecast=today")
Dim baseAddress As New Uri("http://localhost")
Dim fullUri As New Uri("http://localhost/weather/WA/Seattle?forecast=today")
Console.WriteLine("Matching 0} to 1}", template.ToString(), fullUri.ToString())
'Match a URI to a template
Dim results As UriTemplateMatch = template.Match(baseAddress, fullUri)
If (results IsNot Nothing) Then
Console.WriteLine("QueryParameters:")
For Each queryName As String In results.QueryParameters.Keys
Console.WriteLine(" 0} : 1}", queryName, results.QueryParameters(queryName))
Next
Console.WriteLine()
End If
'Code output:
' QueryParameters:
' forecast : today
Remarks
All query string name/value pairs from the original URI appear in this collection, even if they are not explicitly specified in the template string that was matched. The values in this collection have been had all escape sequences translated into actual characters.