HttpWebRequest.Method Property


Gets or sets the method for the request.

Namespace:   System.Net
Assembly:  System (in System.dll)

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.

Exception Condition

No method is supplied.


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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top