【问题标题】:How can I set up my Web API app to be available over the network?如何将我的 Web API 应用程序设置为在网络上可用?
【发布时间】:2014-01-30 21:56:22
【问题描述】:

我可以通过以下方式从浏览器或其他应用程序(例如 Windows 窗体应用程序)连接到我的 Web API 应用程序:

http://localhost:28642/api/inventoryitems/GetAll

...但是我怎样才能让其他人(在同一网络上)可以使用 localhost,以便他们可以进行这些相同的 REST 调用?

是否只是他们连接到我的机器的问题,像这样:

http://platypus:28642/api/inventoryitems/GetAll

...如果是这样,我必须做些什么才能使其可访问(如果有的话)?

无论如何,我真的不想一直在我的机器上运行我的 Web API 应用程序,所以:我怎样才能设置它以便它可以 24/7 运行而无需我启动/保姆吗?

Azure 网站是否是一个有效的选择?

更新

可能是(根据我读到的here)从这里更改 applicationhost.config:

<site name="HandheldServer" id="20">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/"  physicalPath="C:\HandheldServer\HandheldServer" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:28642:localhost" />
      <binding protocol="http" bindingInformation="*:28642:platypus" />
      <binding protocol="https" bindingInformation="*:44300:localhost" />
    </bindings>
</site>

...到这个:

<site name="HandheldServer" id="20">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\HandheldServer\HandheldServer" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:28642:localhost" />
      <binding protocol="http" bindingInformation="*:28642:platypus" />
      <binding protocol="http" bindingInformation="*:28642:" />
      <binding protocol="http" bindingInformation=":28642:" />
      <binding protocol="https" bindingInformation="*:44300:localhost" />
    </bindings>
</site>

...将使其可用(但是,我必须运行它,还是 IISExpress 在后台启动它?)

大概,第一个条目可能已经使它可用。我不知道前面的 * 是否是必要的,所以我有一个有和没有的条目。

【问题讨论】:

    标签: iis azure asp.net-web-api iis-express applicationhost


    【解决方案1】:

    您可以选择:

    • 购买 Rasperberry Pi 以运行独立的服务器/服务而不是您的机器
    • 购买VPS
    • 打开路由器上的防火墙端口
    • 使用您的智能手机(是的,可以)
    • 更改您的主机文件(windows、linux、mac)

    没有奇迹;)

    【讨论】:

    • 我爱我一些 Razzerberry 馅饼(但我更喜欢黑莓和醋栗)。
    • 不知道 gooserberry :) 看起来也不错
    • 如果你曾经在密苏里州的汉尼拔……那是我见过的唯一地方,如果有机会你一定要试试!马克吐温年轻时的一句话是有原因的:“我不会为了馅饼做那种事!”
    猜你喜欢
    • 1970-01-01
    • 2012-07-08
    • 1970-01-01
    • 1970-01-01
    • 2011-02-12
    • 2014-03-02
    • 2014-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多