WebHeaderCollection.Add Inserts the specified header into the collection. : WebHeaderCollection « Network « C# / C Sharp






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

1.Gets an array of header values stored in a header.
2.Tests whether the specified HTTP header can be set for the request.
3.Removes the specified header from the collection.
4.Sets the specified header to the specified value.