在VS调试模式端口:无法访问Web API和IP:端口,但可以与本地主机 [英] Can't access WEB API with ip:port but can with localhost:port during VS debug mode

查看:3156
本文介绍了在VS调试模式端口:无法访问Web API和IP:端口,但可以与本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写从.NET的WEB API,并试图为我的Andr​​oid应用程序从SQL Server数据库中查询一些数据。

I am trying to write an WEB API from .net and trying for my Android Application to query some data from the sql server database.

我的网络API编写的。它可以在调试模式下。

I have the web api written and it works well in debug mode.

我的问题是我注意到,应用程序的URL是本地主机:端口,并运行良好。 但是,当我试图将其更改为 MYIP:端口(例如http:192.168.X.1234) MYHOSTNAME:端口(例如win7home: 1234)这给了我错误的请求 - 无效的主机名

My question is I notice the url of that application is localhost:port and it runs fine. However, when I try to change it to MYIP:port (eg. http:192.168.X.1234) or MYHOSTNAME:port (eg win7home:1234) this gives me Bad Request - Invalid Hostname.

我知道我可以部署这IIS和我的IIS是设置,但我只是想知道怎么就不能在调试模式下工作???

I know I can deploy this to IIS and my IIS is setup but I was just wondering how come it doesn't work in debug mode???

有没有办法对我来说,在调试模式下运行它,并在我的Andr​​oid测试在同一时间,而不必每次我想做出改变部署呢?

Is there a way for me to run it in debug mode and test in on my Android at the same time instead of having to deploy it every time I want to make a change?

推荐答案

安东都和马修的回答向我指出了正确的方向。

Both Anton and Matthew's Answers pointed me to the right direction

所以这就是我所做的。

1)运行视觉工作室在管理员模式

1)Run Visual Studios in administrator mode

2)更改了绑定的协议,并允许进入方向的建议 <一href="http://johan.driessen.se/posts/Accessing-an-IIS-Ex$p$pss-site-from-a-remote-computer">http://johan.driessen.se/posts/Accessing-an-IIS-Ex$p$pss-site-from-a-remote-computer

2)Changed the binding protocols and allow for incoming directions as suggested http://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer

- 但是在那之后,我有不可用的服务(503)错误

-But after that, I have a service unavailable (503) error

3)所以我也跟着这样的: IIS防爆preSS启用外部请求 - 503 仅增加了港口协议和端口:ip协议,

3)So I followed this : IIS Express Enable External Request - 503 Added just the port protocol and port:ip protocol,

<bindings>
    <binding protocol="http" bindingInformation=":1904:" />
    <binding protocol="http" bindingInformation=":1904:10.1.10.123" />
</bindings>

比它的作品无论在我的机器上的浏览器,并在我的手机。

Than it works both on my machine's browser and on my phone.

不算太知道为什么第三个步骤是必需的 - 我的假设是(本地主机URL是需要VS指向的IP地址用于访问从另一台机器)

Not too too sure why the 3rd step is needed -my hypothesis is (the localhost url is needed for VS to point to and the ip url is used for accessing from another machine)

这篇关于在VS调试模式端口:无法访问Web API和IP:端口,但可以与本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆