Method Property

HttpWebResponse.Method Property

Gets the method that is used to return the response.

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

Public ReadOnly Property Method As String
Dim instance As HttpWebResponse
Dim value As String

value = instance.Method

/** @property */
public String get_Method ()

public function get Method () : String

Property Value

A string that contains the HTTP method that is used to return the response.

Exception typeCondition


The current instance has been disposed.

Method returns the method that is used to return the response. Common HTTP methods are GET, HEAD, POST, PUT, and DELETE.

The following example checks the string contained in Method, to determine the Http method invoked by the Web server.

      Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
      Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
      Dim method As String
      method = myHttpWebResponse.Method
      If [String].Compare(method, "GET") = 0 Then
          Console.WriteLine(ControlChars.NewLine + "The GET method was successfully invoked on the following Web Server : {0}", myHttpWebResponse.Server)
      End If
      ' Releases the resources of the response.
  Catch e As WebException
      Console.WriteLine(ControlChars.NewLine + "Exception Raised. The following error occured : {0}", e.Status)
  Catch e As Exception
      Console.WriteLine(ControlChars.NewLine + "The following exception was raised : {0}", e.Message)
  End Try

    try {
        // Creates an HttpWebRequest for the specified URL. 
        HttpWebRequest myHttpWebRequest = (HttpWebRequest)
        HttpWebResponse myHttpWebResponse = (HttpWebResponse)
        String method;
        method = myHttpWebResponse.get_Method();
        if (String.Compare(method, "GET") == 0) {
            Console.WriteLine("\nThe 'GET' method was successfully invoked "
                + "on the following Web Server : {0}", 

        // Releases the resources of the response.
    catch (WebException e) {
        Console.WriteLine("\nWebException raised. The following error "
            + "occured : {0}", e.get_Status());
    catch (System.Exception e) {
        Console.WriteLine("\nThe following Exception was raised : {0}", 
} //GetPage

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

© 2015 Microsoft