Parsi Coders
سورس کد بدست اوردن هدر سایت - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: C# Programming (http://parsicoders.com/forumdisplay.php?fid=55)
+--- موضوع: سورس کد بدست اوردن هدر سایت (/showthread.php?tid=1395)



سورس کد بدست اوردن هدر سایت - Amin_Mansouri - 12-30-2011

Instructions: Import System.Net and System.Text

کد:
private String GetHeaders(string url)
{
System.Net.HttpWebRequest fw = (HttpWebRequest)HttpWebRequest.Create(url/); //Connects to the url
                StringBuilder sb = new StringBuilder(); //Creates a string builder
                //Loops through all the headers
                for (int i = 0; i < fw.GetResponse().Headers.Count; i++)
                {
                    //Adds all the headers to the stringbuilder.
                    sb.AppendLine(fw.GetResponse().Headers[i].ToString());
                }
               return sb.ToString(); //This is how you access the hearders (e.g. Textbox.text = sb.ToString();
}