Reputation: 363
I have to add HTTP_MSDN in header so that whenever I will click on button this HTTP_MSDN should be visible for this url. Please help me.
protected void Page_Load(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("url");
//HttpWebRequest req = WebRequest.Create("http://wap.mobiletashan.com") as HttpWebRequest;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
request.Headers.Add("HTTP_MSDN", "0123456789");
}
protected void Button1_Click(object sender, EventArgs e)
{
NameValueCollection coll;
coll = Request.ServerVariables;
String[] arr1 = coll.AllKeys;
String[] arr2 = coll.GetValues(arr1[0]);
Response.Write(Server.HtmlEncode(arr2[0]));
}
Upvotes: 0
Views: 2045
Reputation: 307
If you need to add your header to request, add it before getting response, like this:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("url");
request.Headers.Add("HTTP_MSDN", "0123456789");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Upvotes: 2