private void Button_Click(object sender, RoutedEventArgs e)
        {
            string url = "http://localhost:30058/api/Products";
            var uriStr = new Uri(url);
            var wc = new WebClient();
            wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringAsyncCompleted);
            wc.DownloadStringAsync(uriStr);            
        }

        void DownloadStringAsyncCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                lbResult.Content = e.Result;
            }
            catch (Exception ex)
            {

                lbResult.Content = ex.Message;

            }
        }

 

posted on 2015-10-28 17:29  zhuang75  阅读(123)  评论(0编辑  收藏  举报