繁体   English   中英

WebClient请求期间发生异常。 在Windows Phone中

[英]An exception occurred during a WebClient request. in windows phone

在这里,我放了我的代码“ WebClient请求期间发生异常”,我放了断点并检查.it,所以将出现此错误。对于开发,我正在将Visual Studio 2012 Ultimate与Windows Phone sdk8.0一起使用,如果请求成功完成而不是我的响应在json字符串中。它将显示在消息框中。现在它向我显示“ System.Net.Webexception:WebClient请求期间发生异常”。

public match()
{
    InitializeComponent();

    Loaded += new RoutedEventHandler(profile1_loaded);

}
void profile1_loaded(object sender, RoutedEventArgs e)
{
    WebClient wc2 = new WebClient();

    var URI = new Uri("http://192.168.1.17/eyematch/rest1-7-2/api/match");

    wc2.Headers["Content-Type"] = "application/x-www-form-urlencoded";

    wc2.UploadStringCompleted += 
              new UploadStringCompletedEventHandler(wc2_UploadStringCompleted);

    wc2.UploadStringAsync(
              URI, "GET", "action=getMatchNotificationData&sKey=" + 
              GlobalVariables.skey + "&uKey=" + GlobalVariables.ukey);
}
private void wc2_UploadStringCompleted(object sender, UploadStringCompletedEventArgs er)
{
    try
    {
        MessageBox.Show(er.Result);
    }
    catch (Exception eu)
    {
        MessageBox.Show(eu.ToString());
    }
}  

先感谢您....

您是在仿真器中还是在物理设备上进行测试? 根据您的网络配置,该地址很可能无法访问(特别是因为它是本地网络IP)。

对遇到此错误消息的其他人的一个有用提示:异常具有.InnerException,因此,如果将上面的代码更改为也输出“ eu.InnerException”,则可以获得更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM