Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Template Property

UriTemplateMatch.Template Property

Gets and sets the UriTemplate instance associated with this UriTemplateMatch instance.

Namespace:  System
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public UriTemplate Template { get; set; }

Property Value

Type: System.UriTemplate
A UriTemplate instance.

This property contains the UriTemplate that the candidate URI matched.

The following code shows how to access the Template 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("Template:");
                Console.WriteLine(results.Template);
            }
            // Code output: 
            // Template: 
            // weather/{state}/{city}?forecast=today

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft