Examine the headers : Web Client : Network C# Source Code


Custom Search

C# Source Code » Network » Web Client »

 

Examine the headers









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Examine the headers. 
 
using System; 
using System.Net; 
 
public class HeaderDemo {  
  public static void Main() { 
 
    // Create a WebRequest to a URI. 
    HttpWebRequest req = (HttpWebRequest) 
           WebRequest.Create("http://www.osborne.com"); 
 
    // Send that request and return the response. 
    HttpWebResponse resp = (HttpWebResponse) 
           req.GetResponse(); 
 
    // Obtain a list of the names. 
    string[] names = resp.Headers.AllKeys; 
 
    // Display the header name/value pairs. 
    Console.WriteLine("{0,-20}{1}\n", "Name", "Value"); 
    foreach(string n in names) 
      Console.WriteLine("{0,-20}{1}", n, resp.Headers[n]); 
 
    // Close the Response.  
    resp.Close(); 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Network
» Web Client