I'm trying to use emulator to connect to the .net Web API
But the emulator always response 405 Method Not Allow
Here is my android code on eclipse
String url1 = "http://192.168.1.106:8085/api/user";
con = (HttpURLConnection) ( new URL(url1).openConnection());
con.setRequestMethod("GET");
con.setDoInput(true);
con.setDoOutput(true);
con.connect();
here is the url run on browser http://192.168.1.106:8085/api/user
[{"userIDs":"asasasas","pwd":"asasas"},{"userIDs":"jacky","pwd":"jacky"},{"userIDs":"danzo","pwd":"danzo"},{"namIDs":"abcdef","pwd":"abc123"}]
here is my api controller on visual studio 2013
public class userController : ApiController
{
[HttpGet]
public List<userlist> Get()
{
var mylist = new List<userlist> { };
var mylist1 = new List<userlist> { };
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
{
string query = "SELECT UserName, password FROM UserProfile, webpages_Membership WHERE UserProfile.UserId = webpages_Membership.UserId;";
SqlCommand command = new SqlCommand(query, connection);
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
var result = new userlist();
result.namIDs = reader.GetString(0);
result.pwd = reader.GetString(1);
mylist.Add(result);
}
reader.Close();
}
connection.Close();
}
return mylist;
}
public class userlist
{
public string userIDs { get; set; }
public string pwd { get; set; }
}
}
I have tried to view all the similar question
and try to put <remove name="WebDAV" />
and try to put [HttpGet]
But still not work to me