首页 > Windows开发 > 详细

Silverlight 调用 web api

时间:2015-10-28 18:50:31      阅读:288      评论:0      收藏:0      [点我收藏+]
        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;

            }
        }

 

Silverlight 调用 web api

原文:http://www.cnblogs.com/GoZhuang/p/4918000.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!