Nic*_*yev 3 c# asp.net rest web-services
我创建了一个简单的 Asp.net Web Api。当我运行代码时,Chrome 正在打开并从 sql server 数据库中获取 xml 数据。这是链接: http://localhost:50599/api/Menu/。这是我的输出:https : //i.stack.imgur.com/hKeZd.png
但是当我输入我的本地地址而不是“localhost”时,它给了我 400 错误。我的 II 正在运行。当我输入 127.0.0.1 或 192.168.1.104 或 localhost IIS 页面正在打开时。
我做了一切打开 127.0.0.1:50599/api/menu 或 192.168.1.104:50599/api/menu 但错误 400 apears。我变了
<binding protocol="http" bindingInformation="*:8080:localhost" />
Run Code Online (Sandbox Code Playgroud)
到
<binding protocol="http" bindingInformation="*:8080:*" />
Run Code Online (Sandbox Code Playgroud)
它对我不起作用。
我怎么解决这个问题。如果我可以完成这项工作,我将从 Android 设备访问此 Api。
我遇到了和你一样的问题,我知道我会重复你做的一些事情,但尽量忍受我。
编辑根解决方案文件夹中的 applicationhost.config。它位于一个名为 .vs 的隐藏文件夹中。
在您的站点中,添加:
<binding protocol="http" bindingInformation="*:port:*" />
<binding protocol="http" bindingInformation="*:port:youripaddress" />
Run Code Online (Sandbox Code Playgroud)
如果您看到 8080 是默认端口,则您在错误的部分。
以管理员模式打开 Visual Studio。
| 归档时间: |
|
| 查看次数: |
4919 次 |
| 最近记录: |