HttpWebResponse.Server HttpWebResponse.Server HttpWebResponse.Server HttpWebResponse.Server Property

Definition

Ruft den Namen des Servers ab, der die Antwort gesendet hat.Gets the name of the server that sent the response.

public:
 property System::String ^ Server { System::String ^ get(); };
public string Server { get; }
member this.Server : string
Public ReadOnly Property Server As String

Eigenschaftswert

Eine Zeichenfolge mit dem Namen des Servers, der die Antwort gesendet hat.A string that contains the name of the server that sent the response.

Ausnahmen

Die aktuelle Instanz wurde verworfen.The current instance has been disposed.

Beispiele

Im folgenden Beispiel wird die Server Eigenschaft, um Web den Namen des Servers in der Konsole anzeigen.The following example uses the Server property to display the Web server's name to the console.

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 );
}
       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);
		}
}
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 occurred : {0}", e.Status)
  Catch e As Exception
      Console.WriteLine(ControlChars.NewLine + "The following exception was raised : {0}", e.Message)
  End Try

Hinweise

Die Server Eigenschaft enthält den Wert des Headers Server mit der Antwort zurückgegeben.The Server property contains the value of the Server header returned with the response.

Gilt für: