WebHeaderCollection::GetValues Method (String)
.NET Framework 4.5
Gets an array of header values stored in a header.
Assembly: System (in System.dll)
Parameters
- header
- Type: System::String
The header to return.
The following example uses the GetValues method to retrieve an array of values for each header in the WebHeaderCollection.
// Create a web request for S"www.msn.com". HttpWebRequest^ myHttpWebRequest = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://www.msn.com" )); myHttpWebRequest->Timeout = 1000; // Get the associated response for the above request. HttpWebResponse^ myHttpWebResponse = dynamic_cast<HttpWebResponse^>(myHttpWebRequest->GetResponse()); // Get the headers associated with the response. WebHeaderCollection^ myWebHeaderCollection = myHttpWebResponse->Headers; for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) { String^ header = myWebHeaderCollection->GetKey( i ); array<String^>^values = myWebHeaderCollection->GetValues( header ); if ( values->Length > 0 ) { Console::WriteLine( "The values of {0} header are : ", header ); for ( int j = 0; j < values->Length; j++ ) Console::WriteLine( "\t {0}", values[ j ] ); } else Console::WriteLine( "There is no value associated with the header" ); } myHttpWebResponse->Close();
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.