I want to run my .Net Web Api simple program on Android App. But it does not run I don't know what is going wrong. the following is the Visual Studio code:
namespace MyFirstWebApi.Controllers { public class ValuesController : ApiController { // GET api/values public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/values/5 public string Get(int id) { return "value"; } // POST api/values public void Post([FromBody]string value) { } // PUT api/values/5 public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 public void Delete(int id) { } } }
I want to run my .Net Web Api simple program on Android App. But it does not run I don't know what is going wrong. the following is the Visual Studio code: namespace MyFirstWebApi.Controllers { public class ValuesController : ApiController { // GET api/values public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/values/5 public string Get(int id) { return "value"; } // POST api/values public void Post([FromBody]string value) { } // PUT api/values/5 public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 public void Delete(int id) { } } } And this is the Android stude code: srvr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String url="http://192.168.56.1:8240/api/values"; final RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this); StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String response) { srveces.setText(response); requestQueue.stop(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { srveces.setText("error"); error.printStackTrace(); requestQueue.stop(); } }); requestQueue.add(stringRequest); } }); I used ip but did'nt work.I used genymotion ip which 10.0.3.15 it also did'nt work. I used http://localhost:8240/api/values it also not work. It run on computer Browser correctly. But I want to show this simple text on my app textview
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)