Consuming ASP.NET Web Api service from other computer in LAN

让人想犯罪 __ 提交于 2020-01-14 09:33:07

问题


I googled about this, but could't find anything which will fix my problem. (I'm new to ASP.NET Web Api)

I built an ASP.NET Web Api and when I run it from visual studio on the local machine everthing is working perfect. (in both cases it work fine, when I use "Use Visual Studio Development Server" and also "Use Local IIS Web server").

The problem is when I tried to call this web service from other computer in the lan network it didn't worked (somthing like: "http://192.168.2.103:8080/api/blabla"). (1) with "Use Visual Studio Development Server" - the client finish with timeout. (2) with "Use Local IIS Web server" - the client received HTTP ERROR 400 "Bad Request - Invalid Hostname" (this when I'm using port 8080 and added rule to windows firewall to pass this port).

I also tried to fully disable windows-firewall, anti-virus and it didn't help.

I have other http web service project implemented in WCF and there everything is OK, I can communicate it from other computer in lan.

NOTE! (1) the other computer is not windows....if it is important) (2) ping between the to computers/adresses is working OK.

I will realy appreciate any help. thanks,

Haim


回答1:


(1) visual studio development server does not support remote connections. See for more details. People try workarounds like setting a reverse proxy in these scenarios.

(2) By "Local IIS web server", I assume you are using IIS Express. Unfortunately, IIS Express doesn't allow remote connections by default. To allow remote connections, see this question.



来源:https://stackoverflow.com/questions/12460562/consuming-asp-net-web-api-service-from-other-computer-in-lan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!