WebSession.URLParameter

From Xojo Documentation

Method

WebSession.URLParameter(Name as String) As String

Supported for all project types and targets.

Returns the value of the specified URL parameter. If the parameter was specified more than once, the value will be a comma separated list of values.

Notes

The URL parameter are the special values that are passed along with the URL after the "?" character. For example:

 http://example.com?my_favorite_number=42&my_name=Ford

Additional parameters are separated by the "&" character. Note that all parameters must be URL encoded (%20 instead of spaces, for example).

If the requested URL parameter is not available, this function returns "".

For URLs that contain a port number, you have to include a "/" before the first parameter:

 http://127.0.0.1:8080/?test=hello

Example

This code in the Session.Open event handler displays the URL parameters in a Text Area on the main web page:

If Self.URLParameterCount > 0 Then
Var parameterName, value As String
For i As Integer = 0 To Self.URLParameterCount - 1
parameterName = Self.URLParameterName(i)
value = Self.URLParameter(parameterName)
WebPage1.TextArea1.AppendText(parameterName + " = " + value + EndOfLine)
Next
End If

When you run a simple app, open a new tab and put this URL in the address field:

   http://example.com?my_favorite_number=42&my_name=Ford

to see the parameters displayed in the TextArea.

See Also

WebSession.URLParameterCount, WebSession.URLParameterExists, WebSession.URLParameterName