使用本地IIS更改Web API项目的主机名

时间:2013-12-26 20:27:10

标签: c# asp.net asp.net-mvc iis asp.net-web-api

我是Web API的新手。我跟着启动项目found on this page,我能够创建一个通过IIS Express工作的Web API项目。接下来,我跟着this tutorial,现在我的项目在IIS中托管(我在Windows 7上运行IIS 7.5)。

我想将主机名更改为“web-api-test”,所以我没有使用“localhost”。当我将主机名更改为“web-api-test”时,我无法从端点获得响应。我正在使用带有“web-api-test / api / values”网址的GET动词的POSTMAN(chrome扩展名)。如果我在Chrome中尝试此功能,Google搜索会接管并尝试搜索该网址。

如何在IIS中更改Web API项目的主机名?

1 个答案:

答案 0 :(得分:2)

您不更改主机名,但在IIS中更改了绑定

http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults/bindings/binding

然后,如果您使用公共DNS服务器并且您无法更改此dnssetting以便它解析为您自己的计算机,则可以使用计算机本地的hosts文件将域指向您的localhost

http://www.bowerwebsolutions.com/wp/2012/how-to-edit-your-local-host-file-for-testing-web-sites/