在Http Head添加值的问题
如何在httpHead 中添加值?
以下是MSDN给出的Demo.但命名空间中找不到printHeaders方法,没有这个方法总是添加不成功。哪位做过这个东东?在ASP.Net 页面中如何实现?缺少哪一个引用。System.Net等我都加过。
谢谢~~ 50~~
===============================
//Create a web request for "www.msn.com".
HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create("http://www.msn.com");
//Get the headers associated with the request.
WebHeaderCollection myWebHeaderCollection = myHttpWebRequest.Headers;
Console.WriteLine("Configuring Webrequest to accept Danish and English language using 'Add' method");
//Add the Accept-Language header (for Danish) in the request.
myWebHeaderCollection.Add("Accept-Language:da");
//Include English in the Accept-Langauge header.
myWebHeaderCollection.Add("Accept-Language:en;q=0.8");
//Get the associated response for the above request.
HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse();
//Print the headers for the request.
printHeaders(myWebHeaderCollection);
myHttpWebResponse.Close();