How do I get ASP.NET Web API (self-hosted) to listen on *only* localhost?

后端 未结 1 499

I\'m following the example here for a self-hosted ASP.NET Web API service. However, when specifying \"localhost\" as the host in the base address, it is translated to \"+\" (mea

相关标签:
1条回答
  • 2021-02-19 21:28

    Set your HostNameComparisonMode property to Exact:

    var config = new HttpSelfHostConfiguration("https://localhost/api/");
    config.HostNameComparisonMode = HostNameComparisonMode.Exact;
    

    See this article for more information on HostNameComparisonMode

    0 讨论(0)
提交回复
热议问题