我编写了一个将数据发送到 ASP.NET 网站的 Android 应用程序。当我测试应用程序时,我收到错误:
连接被
https://localhost:1863
拒绝。
我该如何解决这个问题?另外,如何将这些数据存储到SQL Server中?
HttpClient client1 = new DefaultHttpClient();
HttpPost request = new HttpPost("http://localhost:1863");
String lat = "lat",lng = "lng";
List<NameValuePair> postParameters = new ArrayList<NameValuePair>(3);
postParameters.add(new BasicNameValuePair("lat", lat));
postParameters.add(new BasicNameValuePair("lng", lng));
try {
request.setEntity(new UrlEncodedFormEntity(postParameters));
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
request.setEntity(formEntity);
// request.addHeader("Content-type", "application/x-www-form-urlencoded");
HttpResponse response;
response = client1.execute(request);
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line;
String page = "";
line = in.readLine();
while (line != null)
{
page = page + line;
line = in.readLine();
}
}
catch (ClientProtocolException e) {
e.printStackTrace();} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}