【发布时间】:2015-11-08 07:08:35
【问题描述】:
我正在尝试获取网站的源代码。在 Windows 应用程序中,一个简单的 http 请求就足够了。但是在windows phone中它要复杂得多。 我在谷歌上搜索了很多,并没有给出明确的答案。 这是我尝试过但没有取得很大成功的方法。
public static sReturn = "";
private string _InetGetSourceCode(string sUrl)
{
_InetReadEx(sUrl);
return sReturn;
}
private void _InetReadEx(string sUrl)
{
WebClient client = new WebClient();
client.DownloadStringCompleted += new
DownloadStringCompletedEventHandler(DownloadStringCallback2);
client.DownloadStringAsync(new Uri(sUrl));
}
private static void DownloadStringCallback2(Object sender,DownloadStringCompletedEventArgs e)
{
if (!e.Cancelled && e.Error == null)
{
sReturn = e.Result;
}
}
我在这里做错了什么?
【问题讨论】:
-
你说的“没有大成功”是什么意思?
-
我只是在报废样品,似乎没有任何效果。
-
似乎不起作用,比如... 例外?所有数据都大写?编码问题?超时?爆手机? WhatsApp 的高分被抹去?如果您无法对问题做出清晰的解释,我们将如何给出解决方案?
标签: c# windows web-services visual-studio windows-phone-8