using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace WPWebRequestHead
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://blogs.compactframework.de/Peter.Nowak/content/binary/WindowsLiveWriter/WP7SDKNewprojectweirdbehaviour_11A76/FrameRateCounter_2.png");
            request.Method = "HEAD";
            request.BeginGetResponse(ProcessSize, request);
        }
        private void ProcessSize(IAsyncResult result)
        {
            if (result.IsCompleted)
            {
                HttpWebRequest request = (HttpWebRequest)result.AsyncState;
                if (request.HaveResponse)
                {
                    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
                    Dispatcher.BeginInvoke(() =>
                        //Ausgabe der Dateigröße in Bytes
                        MessageBox.Show(response.Headers["Content-Length"].ToString()
                        ));
                }
            }
        }
    }
}