當使用VS IDE進行web api專案debug階段,預設使用IIS Express並host,hostname預設也使用localhost,如下圖

但有時候我需要在其他VM打webapi進行測試,當我把localhost改為IP address,
chrome會出現Bad request-invalid hostname錯誤

查看IIS Express中的該站台,確實只有binding localhost

要能正確使用IP address,我只需要多新增一組IP的綁定即可,
針對該站台進行組態修改,新增以下內容

<binding protocol="http" bindingInformation="192.168.137.1:5110:*" />

透過chrome也能正常送出http request

參考

