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

1

6

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

Marje answered 17/9, 2012 at 13:43 Comment(4)
What happens when you use 192.168.2.103:8080/api/blabla rather than localhost on the local computer?Riocard
If I'm using 192.168.2.103:8080/api/blabla I get the same problem, HTTP ERROR 400 "Bad Request - Invalid Hostname".Marje
@Marje am facing the same problem.... did u find any solution for this?Isabea
blog.kloud.com.au/2017/02/27/…Overheat
A
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.

Africander answered 8/10, 2012 at 3:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.