从局域网中的其他计算机上使用ASP.NET Web Api服务 [英] Consuming ASP.NET Web Api service from other computer in LAN

查看:88
本文介绍了从局域网中的其他计算机上使用ASP.NET Web Api服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google上搜索了此内容,但找不到能解决我的问题的任何内容.(我是ASP.NET Web Api的新手)

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

我构建了一个ASP.NET Web Api,当我从本地计算机上的Visual Studio中运行它时,一切运行正常.(在两种情况下,当我同时使用使用Visual Studio开发服务器"和使用本地IIS Web服务器"时,它都可以正常工作.)

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").

问题是,当我尝试从局域网中的其他计算机上调用此Web服务时,它没有工作(诸如:"http://192.168.2.103:8080/api/blabla").(1)与使用Visual Studio开发服务器"一起使用-客户端完成超时.(2)使用使用本地IIS Web服务器"时-客户端收到HTTP ERROR 400错误请求-无效的主机名"(当我使用端口8080并将规则添加到Windows防火墙以通过此端口时).

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

我还尝试完全禁用Windows防火墙,防病毒软件,但没有帮助.

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

我在WCF中实现了其他http Web服务项目,一切正常,我可以从局域网中的其他计算机进行通信.

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

注意!(1)另一台计算机不是Windows ....如果重要的话)(2)在计算机/地址之间ping通正常.

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,

海姆

推荐答案

(1)Visual Studio开发服务器不支持远程连接.请参阅以了解更多详细信息.人们尝试在这些情况下设置反向代理之类的变通办法.

(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)通过本地IIS Web服务器",我假设您正在使用IIS Express.不幸的是,默认情况下,IIS Express不允许远程连接.要允许远程连接,请参阅此问题.

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

这篇关于从局域网中的其他计算机上使用ASP.NET Web Api服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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