HttpWebResponse.Method プロパティ
アセンブリ: System (system.dll 内)




Method に格納されている文字列を確認し、Web サーバーで呼び出される Http メソッドを確認する例を次に示します。
Try 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. myHttpWebResponse.Close() 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)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 occured : {0}",e.Status); } catch(Exception e) { Console.WriteLine("\nThe following Exception was raised : {0}" ,e.Message); } }
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 occured : {0}", e->Status ); } catch ( Exception^ e ) { Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); }
try { // Creates an HttpWebRequest for the specified URL. HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(url); HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse(); 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}", myHttpWebResponse.get_Server()); } // Releases the resources of the response. myHttpWebResponse.Close(); } 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}", e.get_Message()); } } //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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHttpWebResponse.Method プロパティを検索する場合は、下記のリンクをクリックしてください。

- HttpWebResponse.Method プロパティのページへのリンク