How to solve the exception of type 'System.Net.WebException' occurred while running app? <p>I want to connect windows phone with remote server.</p> <p>I trying to connect that time the below error occurred. How to solve it.</p> <p><strong>An exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary</strong></p> <p>Here mycode</p> <p><strong>C# code</strong></p> <p>ProgressIndicator prog;</p> <pre><code> private void btnLogin_Click(System.Object sender, System.Windows.RoutedEventArgs e) { try { string url = "http://192.168.2.112/check_login/check.php"; //string url = "http://localhost/sam.php"; Uri uri = new Uri(url, UriKind.Absolute); StringBuilder postData = new StringBuilder(); postData.AppendFormat("{0}={1}", "sUsername", HttpUtility.UrlEncode(this.txtUsername.Text)); postData.AppendFormat("&amp;{0}={1}", "sPassword", HttpUtility.UrlEncode(this.txtPassword.Password.ToString())); WebClient client = default(WebClient); client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; client.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString(); client.UploadStringCompleted += client_UploadStringCompleted; client.UploadProgressChanged += client_UploadProgressChanged; client.UploadStringAsync(uri, "POST", postData.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } prog = new ProgressIndicator(); prog.IsIndeterminate = true; prog.IsVisible = true; prog.Text = "Loading...."; SystemTray.SetProgressIndicator(this, prog); } private void client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e) { //Me.txtResult.Text = "Uploading.... " &amp; e.ProgressPercentage &amp; "%" } private void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) { if (e.Cancelled == false &amp; e.Error == null) { prog.IsVisible = false; MessageBox.Show(e.Result.ToString()); } } </code></pre> <p><strong>PHP code</strong></p> <pre><code> &lt;?php $hostname_localhost ="localhost"; $database_localhost ="androidlogin"; $username_localhost ="root"; $password_localhost =""; $localhost=mysql_connect($hostname_localhost,$username_localhost,$password_localhost) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_localhost, $localhost); $username = $_POST['username']; $password = $_POST['password']; $query_search = "select * from user where username = '".$username."' AND password = '".$password. "'"; $query_exec = mysql_query($query_search) or die(mysql_error()); $rows = mysql_num_rows($query_exec); //echo $rows; if($rows == 0) { echo "No Such User Found"; } else { echo "User Found"; } ?&gt; </code></pre> <p>Please help me. Thanks in advance.</p>