Sys.Net.WebRequest httpVerb Property
Gets or sets the HTTP verb that was used by the Sys.Net.WebRequest class to issue the Web request.
Note
To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.
var verb = MyWebRequest.get_httpVerb();
MyWebRequest.set_httpVerb(value);
Parameters
Parameter |
Description |
---|---|
value |
A string that contains the HTTP verb for the Web request. value must be an HTTP verb that is recognized by the Web server, such as "GET" or "POST". |
Return Value
The current Web request verb.
Exceptions
Exception type |
Condition |
---|---|
value cannot be null or an empty string (""). |
Remarks
If the HTTP verb has not been previously set, the httpVerb property value is determined based on the following logic:
If the value of the body property is null, the WebRequest instance returns "GET".
If the value of the body property is not null, the WebRequest instance returns "POST". If the returned body is an empty string (""), this is considered not null and "POST" is returned.
Example
The following example shows how to set the HTTP verb for the Web request. This code is part of a complete example found in the WebRequest class overview.
// Set the request verb.
wRequest.set_httpVerb("POST");
See Also
Reference
Sys.Net.WebRequestManager Class