稳扎稳打Silverlight(21) - 2.0通信之WebRequest和WebResponse……2010-04-26 cnblogs webabcd稳扎稳打Silverlight(21) - 2.0通信之WebRequest和WebResponse,对指定的URI发出请求以及接收响应介绍Silverlight 2.0 详解WebRequest和WebResponse,对指定的URI做GET和POST请求,以及接收其响应HttpWebRequest - 对指定的 URI 发出请求Create() - 初始化一个 WebRequestBeginGetResponse() - 开始对指定 URI 资源做异步请求EndGetResponse() - 结束对指定 URI 资源做异步请求HttpWebResponse - 对指定的 URI 做出响应GetResponseStream() - 获取响应的数据流示例1、对指定的URI做GET请求以及接收响应WebRequestGet.xaml<UserControl x:Class="Silverlight20.Communication.WebRequestGet" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <StackPanel HorizontalAlignment="Left" Margin="5">
<TextBlock x:Name="lblMsg" />
</StackPanel> </UserControl>WebRequestGet.xaml.csusing 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 System.Threading; using System.IO;
namespace Silverlight20.Communication { public partial class WebRequestGet : UserControl { // 接收 GET 方式数据的 REST 服务 string _url = "http://localhost:3036/REST.svc/Users/json";