2012-04-17 63 views
1

我編寫了一個將數據發送到ASP.NET網站的Android應用程序。當我測試應用程序,我得到的錯誤:從ASP.NET網站接收Android數據

Connection to https://localhost:1863 refused.

我該如何解決這個問題?另外,如何將這些數據存儲到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(); 
} 

回答

-1

我做了一個ASP.NET處理程序頁面(.ashx),將其命名爲Handler,並用「http:// localhost:1863/Handler.ashx」替換了「http:// localhost:1863」,並解決了問題。