Get headers using httpwebrequest and httpwebresponse
using System.Net;
private void getUrlHeaders()
{
HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://localhost/yourfile.aspx");
HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
string[] names = resp.Headers.AllKeys;
foreach (string n in names) {
Response.Write(n + " : " + resp.Headers[n] + "<br>");
}
resp.Close();
}
//output
Content-Length : 2141
Cache-Control : private
Content-Type : text/html; charset=utf-8
Date : Thu, 23 Aug 2007 23:10:27 GMT
Server : Microsoft-IIS/5.1X-AspNet-Version : 2.0.50727
X-Powered-By : ASP.NET
No comments:
Post a Comment