Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 722
Haim Avatar asked Nov 12 '22 22:11

Haim


1 Answers

(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.

like image 113
RaghuRam Nadiminti Avatar answered Jan 04 '23 03:01

RaghuRam Nadiminti