如何使用在 Visual Studio 中使用 webapi 构建并在 IIS 中发布的休息服务

How consume rest service that was built using webapi in Visual Studio and published in IIS

我按照教程构建了 REST 服务 https://www.youtube.com/watch?v=JeIE3jzAxHU

我已经使用 Visual Studio 在 IIS 中发布了它。但我不明白如何消费它。在 IIS Express 下工作的示例中,它被称为 本地主机:port/api/person.
当我在 IIS 中发布服务时,我看到许多已编译的文件,但我不明白应该调用哪个地址才能获得与在 IIS Express 下相同的结果。

试试这个得到 url:

  • 打开 IIS
  • 展开左边的树,直到看到 Sites
  • Select 你为演示制作的那个
  • 单击最右侧窗格中 Browse Website 标题下的 Browse *:port

这将为您提供用于测试的基本站点 url,然后只需从那里添加 api/person

可能 http://localhost/api/person,除非演示真的很奇怪。如果您仍无法浏览网站,请向我们提供更多信息(错误?)或至少提供屏幕截图。