HttpWebResponse.Method Özellik

Tanım

Yanıtı döndürmek için kullanılan yöntemi alır.

C#
public virtual string Method { get; }
C#
public string Method { get; }

Özellik Değeri

Yanıtı döndürmek için kullanılan HTTP yöntemini içeren bir dize.

Özel durumlar

Geçerli örnek atıldı.

Örnekler

Aşağıdaki örnek, Web sunucusu tarafından çağrılan Http yöntemini belirlemek için içinde Methodyer alan dizeyi denetler.

C#
    try
      {	
        // Creates an HttpWebRequest for the specified URL.
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            string method ;
            method = myHttpWebResponse.Method;
            if (String.Compare(method,"GET") == 0)
                Console.WriteLine("\nThe 'GET' method was successfully invoked on the following Web Server : {0}",
                                   myHttpWebResponse.Server);
            // Releases the resources of the response.
            myHttpWebResponse.Close();
      }
    catch(WebException e)
       {
            Console.WriteLine("\nWebException raised. The following error occurred : {0}",e.Status);
       }
    catch(Exception e)
        {
            Console.WriteLine("\nThe following Exception was raised : {0}",e.Message);
        }
}

Açıklamalar

Method yanıtı döndürmek için kullanılan yöntemi döndürür. Yaygın HTTP yöntemleri GET, HEAD, POST, PUT ve DELETE yöntemleridir.

Şunlara uygulanır

Ürün Sürümler
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0