GetFirstValueByName | getFirstValueByName method

WwwFormUrlDecoder.GetFirstValueByName | getFirstValueByName method

Gets the first name-value pair that has the specified name, as obtained from the constructing Uniform Resource Identifier (URI) query string.

Syntax


public:
String^ GetFirstValueByName(
  String^ name
)

Parameters

name

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The name of the value to get.

Return value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The first value in list order that corresponds with name.

Remarks

This method throws an exception (an error for JavaScript) if the value specified as name doesn't exist in the WwwFormUrlDecoder collection. For .NET code, this is typed as System.ArgumentException. You'll probably want to call GetFirstValueByName within a try-catch block so you have a chance to handle the exception.

What to do with duplicate names in a query string from a GET request is not specified by any Internet standard. A common practice is to process the first value and ignore the subsequent duplicates. The GetFirstValueByName method provides that behavior. It also provides the de-facto "index by string" behavior, which is typically what you want when you're processing a query string. Your app is expecting certain names to be present on the query string, and wants to retrieve the associated value.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Foundation
Windows::Foundation [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Foundation
Windows::Foundation [C++]

Metadata

Windows.winmd

See also

WwwFormUrlDecoder

 

 

Show:
© 2016 Microsoft