15 Eylül 2014 Pazartesi

c# Web site header bilgileri alma

Web site header bilgileri alma 2014 C#

using System.Net;
 
//...
 
public Dictionary getHeaders(string url)
{
    //Dictionary which shall contain the header information
    Dictionary header = new Dictionary();
 
    //Create webrequest
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
 
    //Create response object
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
 
    //Read all headers from the response
    foreach (string headerItem in response.Headers)
    {
        //Add header to the dictionary
        header.Add(headerItem, response.Headers[headerItem]);
    }
 
    //Close webrequest
    response.Close();
 
    //return header information
    return header;
}

    Hiç yorum yok:

    Yorum Gönder