Removes the specified header from the collection.
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
class MainClass
{
public static void Main()
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.msn.com");
WebHeaderCollection myWebHeaderCollection = myHttpWebRequest.Headers;
myWebHeaderCollection.Set("Cache-Control", "no-cache");
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
myWebHeaderCollection.Remove("Cache-Control");
myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("Print request headers after removing Cache-Control for the new request:");
myHttpWebResponse.Close();
}
}
Related examples in the same category