我正在效仿这个例子 这里 用于自托管的ASP.NET Web API服务。但是,当将“localhost”指定为基址中的主机时,它将被转换为“+”(表示“全部可用”)。
var baseAddress = new Uri("http://localhost:13210");
var configuration = new HttpSelfHostConfiguration(baseAddress);
configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new {id = RouteParameter.Optional});
using (var server = new HttpSelfHostServer(configuration))
{
server.OpenAsync().Wait();
stop.WaitOne();
server.CloseAsync().Wait();
}
我真的希望我的主机只能绑定到“localhost” - 它只能从同一台机器上访问,而且我不想乱用URL ACL。
如何配置Web API 不 将“localhost”重写为“+”?