405 Method Not Allow When Emulator Connect To Web API
<p>I'm trying to use emulator to connect to the .net Web API </p>

<p>But the emulator always response 405 Method Not Allow</p>

<p>Here is my android code on eclipse</p>

<pre><code>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();
</code></pre>

<p>here is the url run on browser <a href="http://192.168.1.106:8085/api/user" rel="nofollow">http://192.168.1.106:8085/api/user</a></p>

<pre><code>[{"userIDs":"asasasas","pwd":"asasas"},{"userIDs":"jacky","pwd":"jacky"},{"userIDs":"danzo","pwd":"danzo"},{"namIDs":"abcdef","pwd":"abc123"}]
</code></pre>

<p>here is my api controller on visual studio 2013</p>

<pre><code>public class userController : ApiController
{
    [HttpGet]
    public List&lt;userlist&gt; Get()
    {

        var mylist = new List&lt;userlist&gt; { };
        var mylist1 = new List&lt;userlist&gt; { };
        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; }
    }

}
</code></pre>

<p>I have tried to view all the similar question</p>

<p>and try to put <code>&lt;remove name="WebDAV" /&gt;</code></p>

<p>and try to put [HttpGet]</p>

<p>But still not work to me</p>