IIS Express 错误的主机名 android studio

IIS Express bad hostname android studio

我知道这个问题已被问过一百万次,但我仍然不明白为什么它不起作用。 我想从我的 android 模拟器(android 工作室)访问我的 asp .net api,但我总是收到错误 400 主机名无效。我已经查看了有关它的每个主题,但它仍然无法正常工作。我添加了这三行

<binding protocol="http" bindingInformation="*:51755:127.0.0.1" /> <binding protocol="http" bindingInformation="*:51755:*" /> <binding protocol="http" bindingInformation="*:51755:172.20.10.9" />

进入我的 C:\Program Files (x86)\IIS Express\config\templates\PersonalWebServer\applicationhost.config 但它仍然无法正常工作。

这是 android studio

上的代码
AsyncHttpClient client = new AsyncHttpClient();
                RequestParams parameters = new RequestParams();
                parameters.put("userName","test");
                parameters.put("password","test1234");
                parameters.add("confirmPassword","test1234");
                client.post("http://10.0.2.2:51755/api/orders",parameters, new JsonHttpResponseHandler(){
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                        // Root JSON in response is an dictionary i.e { "data : [ ... ] }
                        // Handle resulting parsed JSON response here

                        text.setText(response.toString());
                    }

                    @Override
                    public void onFailure(int statusCode, Header[] headers, String res, Throwable t) {
                        // called when response HTTP status is "4XX" (eg. 401, 403, 404)
                        text.setText(res.toString());
                    }
                });

我不明白为什么它还不起作用,因为我关注了我在每个主题上发现的每件事。

  1. 为了让 IIS Express 响应任何 IP 地址,请将地址留空,即:bindingInformation=":51755:"

  2. 此外,IIS Express 必须 运行 作为管理员才能绑定到本地主机以外的任何内容。

  3. 检查你的防火墙和路由 table