par*_*man 6 asp.net-mvc android
谁能告诉我一个简单的例子,用json格式从android发布数据到asp mvc web服务器?我使用它来从asp.net mvc获取数据到json格式的android:
new Thread() {
public void run() {
try{
JsonNode userData = null;
ObjectMapper mapper = new ObjectMapper();
HttpResponse res;
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost(URI.create("http://mylink.com/test/api"));
res = httpclient.execute(post);
userData = mapper.readValue(res.getEntity().getContent(), JsonNode.class);
name= (String)userData.get("name").getTextValue();
}catch(Exception e){
Log.e("activity","dead",e);
}
}
}.start();
editStatus.setText(name);
Run Code Online (Sandbox Code Playgroud)
在asp.net中:
[HttpPost]
public ActionResult Api()
{
return Json(new { name = "test" });
}
Run Code Online (Sandbox Code Playgroud)
它非常适合从asp.net mvc web服务器获取数据但是如何将数据从android发送到带有json格式或其他格式的asp.net mvc控制器?
| 归档时间: |
|
| 查看次数: |
1380 次 |
| 最近记录: |