Get or set a collection of header name/value pairs associated with the request in CSharp
Description
The following code shows how to get or set a collection of header name/value pairs associated with the request.
Example
using System;// w w w .ja v a 2s . com
using System.Net;
using System.Net.Sockets;
using System.Text;
public class Example
{
public static void Main()
{
string uriString = "http://www.java2s.com";
WebClient myWebClient = new WebClient();
string postData = "data";
myWebClient.Headers.Add("Content-Type","application/x-www-form-urlencoded");
Console.WriteLine(myWebClient.Headers.ToString());
}
}
The code above generates the following result.