Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

UriTemplate.BindByName Method (Uri, NameValueCollection)

Creates a new URI from the template and the collection of parameters.

Namespace:  System
Assembly:  System.ServiceModel.Web (in System.ServiceModel.Web.dll)
public Uri BindByName(
	Uri baseAddress,
	NameValueCollection parameters
)

Parameters

baseAddress
Type: System.Uri

A Uri that contains the base address.

parameters
Type: System.Collections.Specialized.NameValueCollection

A NameValueCollection instance that contains the parameter values.

Return Value

Type: System.Uri
A new Uri instance.

The NameValueCollection parameter contains a collection of parameter name and value pairs. The parameters are matched up against the variables within the template by a case-insensitive comparison. Values passed in this collection are escaped.

NoteNote:

The name/value collection passed to BindByName(Uri, NameValueCollection) must contain a key for every template variable. Extra name/value pairs that do not match template variables are appended to the query string of the final URI.

NoteNote:

It is possible to pass in text within the name/value pairs that prevent the generated URI from matching the template that is used to generate it. Examples of such text includes: '/', '..', '*', '{', and '}'.

The following example shows how to call the BindByName(Uri, NameValueCollection) method.

UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast={day}");
Uri prefix = new Uri("http://localhost");

NameValueCollection parameters = new NameValueCollection();
parameters.Add("state", "Washington");
parameters.Add("city", "Redmond");
parameters.Add("day", "Today");
Uri namedUri = template.BindByName(prefix, parameters);

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.