WebHeaderCollection.Add Inserts the specified header into 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.Add("Accept-Language:da");
myWebHeaderCollection.Add("Accept-Language", "en;q=0.8");
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
}
}
Related examples in the same category