Get HTTP Response headers : Web Request Response : Network C# Source Code


Custom Search

C# Source Code » Network » Web Request Response »

 

Get HTTP Response headers








    

using System;
using System.IO;
using System.Net;

public class TryHttpRequest {
  public static void Main(String [] args) {
    HttpWebRequest request =(HttpWebRequest)WebRequest.Create("http://www.navioo.com");
    HttpWebResponse response =(HttpWebResponse)request.GetResponse();
    request.Accept = "text/plain";
    
    Console.WriteLine("Response headers");
    Console.WriteLine("  Protocol version: {0}",                                             response.ProtocolVersion);
    Console.WriteLine("  Status code: {0}",response.StatusCode);
    Console.WriteLine("  Status description: {0}",response.StatusDescription);
    Console.WriteLine("  Content encoding: {0}",response.ContentEncoding);
    Console.WriteLine("  Content length: {0}",response.ContentLength);
    Console.WriteLine("  Content type: {0}",response.ContentType);
    Console.WriteLine("  Last Modified: {0}",response.LastModified);
    Console.WriteLine("  Server: {0}", response.Server);
    Console.WriteLine("  Length using method: {0}\n",response.GetResponseHeader("Content-Length"));
  
  }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Network
» Web Request Response