HttpWebResponse.Cookies : HttpWebResponse « System.Net « C# / C Sharp by API






HttpWebResponse.Cookies

  

using System; 
using System.Net; 
 
public class CookieDemo {  
  public static void Main(string[] args) { 
    HttpWebRequest req = (HttpWebRequest) WebRequest.Create("yourURL");  
    req.CookieContainer = new CookieContainer(); 
    HttpWebResponse resp = (HttpWebResponse) req.GetResponse(); 
 
    Console.WriteLine("Number of cookies: " +  resp.Cookies.Count); 
    Console.WriteLine("{0,-20}{1}", "Name", "Value"); 
 
    for(int i=0; i < resp.Cookies.Count; i++) 
      Console.WriteLine("{0, -20}{1}", resp.Cookies[i].Name, resp.Cookies[i].Value); 
 
    resp.Close(); 
  } 
}

   
    
  








Related examples in the same category

1.HttpWebResponse.GetResponseStream()
2.HttpWebResponse.Headers.AllKeys
3.HttpWebResponse.LastModified