Export (0) Print
Expand All

HttpWebRequest.Method Property

Gets or sets the method for the request.

Namespace:  System.Net
Assemblies:   System.Net.Requests (in System.Net.Requests.dll)
  System (in System.dll)

abstract Method : string with get, set 
override Method : string with get, set

Property Value

Type: System.String
The request method to use to contact the Internet resource. The default value is GET.

ExceptionCondition
ArgumentException

No method is supplied.

-or-

The method string contains invalid characters.

The Method property can be set to any of the HTTP 1.1 protocol verbs: GET, HEAD, POST, PUT, DELETE, TRACE, or OPTIONS.

If the ContentLength property is set to any value other than -1, the Method property must be set to a protocol property that uploads data.

The following code example sets the Method property to POST.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft