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

応答の HTTP プロトコルのバージョンを格納する Version。



この例では、HttpWebRequest を作成し、HttpWebResponse を問い合わせます。この例では、次に、サーバーが同じバージョンで応答するかどうかを確認します。
Dim ourUri As New Uri(url) ' Creates an HttpWebRequest with the specified URL. Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(ourUri), HttpWebRequest) myHttpWebRequest.ProtocolVersion = HttpVersion.Version10 ' Sends the request and waits for the response. Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse) 'The ProtocolVersion property is used to ensure that only Http/1.0 responses are accepted. If myHttpWebResponse.ProtocolVersion Is HttpVersion.Version10 Then Console.WriteLine(ControlChars.NewLine + "The server responded with a version other than Http/1.0") Else If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then Console.WriteLine(ControlChars.NewLine + "Request sent using version HTTP/1.0. Successfully received response with version Http/1.0 ") End If End If ' Releases the resources of the response. myHttpWebResponse.Close()
Uri ourUri = new Uri(url); // Creates an HttpWebRequest for the specified URL. HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(ourUri); myHttpWebRequest.ProtocolVersion = HttpVersion.Version10; // Sends the HttpWebRequest and waits for the response. HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); // Ensures that only Http/1.0 responses are accepted. if(myHttpWebResponse.ProtocolVersion != HttpVersion.Version10) Console.WriteLine("\nThe server responded with a version other than Http/1.0"); else if (myHttpWebResponse.StatusCode == HttpStatusCode.OK) Console.WriteLine("\nRequest sent using version Http/1.0. Successfully received response with version HTTP/1.0 "); // Releases the resources of the response. myHttpWebResponse.Close();
Uri^ ourUri = gcnew Uri( url ); // Creates an HttpWebRequest for the specified URL. HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( ourUri ) ); myHttpWebRequest->ProtocolVersion = HttpVersion::Version10; // Sends the HttpWebRequest and waits for the response. HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); // Ensures that only Http/1.0 responses are accepted. if ( myHttpWebResponse->ProtocolVersion != HttpVersion::Version10 ) { Console::WriteLine( "\nThe server responded with a version other than Http/1.0" ); } else if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) { Console::WriteLine( "\nRequest sent using version Http/1.0. Successfully received response with version HTTP/1.0 " ); } // Releases the resources of the response. myHttpWebResponse->Close();
Uri ourUri = new Uri(url); // Creates an HttpWebRequest for the specified URL. HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(ourUri); myHttpWebRequest.set_ProtocolVersion(HttpVersion.Version10); // Sends the HttpWebRequest and waits for the response. HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse(); // Ensures that only Http/1.0 responses are accepted. if (!myHttpWebResponse.get_ProtocolVersion(). Equals(HttpVersion.Version10)) { Console.WriteLine("\nThe server responded with a version " + "other than Http/1.0"); } else { if (myHttpWebResponse.get_StatusCode(). Equals(HttpStatusCode.OK)) { Console.WriteLine("\nRequest sent using version Http/1.0. " + "Successfully received response with version " + "HTTP/1.0 "); } } // Releases the resources of the response. myHttpWebResponse.Close();

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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