简体   繁体   中英

An exception occurred during a WebClient request. in windows phone

Here I am put my code which is "An exception occurred during a WebClient request" i put breakpoint and check .it will so this error .for developing i am using visual studio 2012 ultimate with windows phone sdk8.0 and if request is done successful than my response is in json string .that will show in messagebox .now it show me "System.Net.Webexception:An exception occurred during a WebClient request."

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());
    }
}  

thank you in advance....

Are you testing this in the emulator or on a physical device? Chances are the address is inaccessible given your network configuration (especially since it is a local network IP).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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