积极答复者
image加载网络图片遇到问题

问题
-
http://regcheckcode.taobao.com/auction/checkcode?sessionID=a2b3e64c8ab1f8b928999689429e9371&t=1369277957871
这个连接是淘宝的验证码地址 刷新这个图片会变
做的是点击按钮的时候 换一个图片
按钮事件
private void changeBtn_Click(object sender, RoutedEventArgs e) { img.Source = null; BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri("https://regcheckcode.taobao.com/auction/checkcode?sessionID=a2b3e64c8ab1f8b928999689429e9371&t=1369277957871", UriKind.RelativeOrAbsolute); bi.EndInit(); img.Source = bi; }
请问为什么图片不会变呢 要怎么让图片向在浏览器里面刷新一样会变呢
答案
-
可以参考下面的代码直接显示发送请求到服务器。
BitmapImage bi = new BitmapImage(); bi.BeginInit(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://regcheckcode.taobao.com/auction/checkcode?sessionID=a2b3e64c8ab1f8b928999689429e9371&t=1369277957871"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); bi.StreamSource = response.GetResponseStream(); bi.EndInit(); img.Source = bi;
祝,万好。
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已编辑 Dummy yoyoModerator 2013年5月24日 8:41
- 已标记为答案 huanghy 2013年5月24日 10:03
全部回复
-
可以参考下面的代码直接显示发送请求到服务器。
BitmapImage bi = new BitmapImage(); bi.BeginInit(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://regcheckcode.taobao.com/auction/checkcode?sessionID=a2b3e64c8ab1f8b928999689429e9371&t=1369277957871"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); bi.StreamSource = response.GetResponseStream(); bi.EndInit(); img.Source = bi;
祝,万好。
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已编辑 Dummy yoyoModerator 2013年5月24日 8:41
- 已标记为答案 huanghy 2013年5月24日 10:03