[英]IIS Express bad hostname android studio
我知道这个问题已经被问了一百万次,但我仍然无法弄清楚为什么它不起作用。 我想从我的 android 模拟器(android studio)访问我的 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());
}
});
我不知道为什么它还不起作用,因为我跟踪了我在每个主题上找到的所有内容。
为了让 IIS Express 回答任何 IP 地址,只需将地址留空,即:bindingInformation=":51755:"
此外,IIS Express 必须以管理员身份运行才能绑定到除本地主机之外的任何内容。
检查您的防火墙和路由表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.