HTTP Input Parameters to MildServer Pages

HTTP has two primary mechanisms for passing input parameters to server-side scripts. Regardless of which mechanism is used, the MildServer will extract parameter names and values from the request for you. Wherever the name of a parameter matches the name of a public field or property exposed by the referenced page, the corresponding value is assigned to that member before the Render method is called.

Parameters in the URL of an HTTP GET

The first mechanism embeds parameters in the HTTP GET command itself, as part of the URL (Unique Resource Locator). In the example on the main MildServer page, the request was for a resource named:

http://localhost:8080/reverse?Name=Beethoven&Action=Reverse

This is interpreted as a request for the page called reverse, with values assigned to two parameters. This form of parameter passing has the advantage that it can be embedded in any link on a web page: DIrecting a browser to this URL is the equivalend of a function call with named arguments. Browesers will generate this kind of request automatically when an HTTP page contains a Form with the attrribute "Method=Submit" and a button in the form is pressed (or another event is triggered): A GET command is generated where the values of all input fields in the form have been added to the URL of the active page. Due to limitations on the format of URLs, this mechanism is only suitable when all parameters contain simple string values.

Parameters used by HTTP POST

When an HTML page contains a Form with the attribute "Method=Post", and the form is submitted, an HTTP "POST" command is generated. In this case, the URL only contains the name of the active page, and the HTTP request contains a header element called "content-type" which has the value "multipart/form-data". The data for each input field en encoded as text in the data part of the HTTP request. This form of encoding is more suitable for complex forms with large quantities of data.

For example, if we modify the file Reverse example so that the form is of type Post (by changing the operand to the Form operator from Submit to Post), an HTTP request similar to the following will be generated when the Reverse button is pressed:

POST /reverse.dyalog HTTP/1.1
(headers snipped)
Content-Type: multipart/form-data; boundary=---------------------------7d88a3130dc6
(headers snipped)
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
Host: localhost:8080
Content-Length: 247
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: Session=9f4GAB9h0JKQmwWLqD0Alq62n/vWo9RaxwC7ODFSiwc=
-----------------------------7d88a3130dc6
Content-Disposition: form-data; name="Name"
Beethoven
-----------------------------7d88a3130dc6
Content-Disposition: form-data; name="Action"
Reverse
-----------------------------7d88a3130dc6--