本文介绍了Web API自托管-在所有网络接口上绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使Web API自托管主机在所有网络接口上绑定?
How do you make a Web API self host bind on all network interfaces?
我目前有以下代码.不幸的是,它仅在本地主机上绑定.因此,无法从本地主机访问该服务器.
I have the below code currently. Unfortunately, it binds only on localhost. So access to this server from other than localhost is failing.
var baseAddress = string.Format("localhost:9000/"); using (WebApp.Start<Startup> (baseAddress)) { Console.WriteLine("Server started"); Thread.Sleep(1000000); }推荐答案
只需像这样更改基址
var baseAddress = "*:9000/"; using (WebApp.Start<Startup> (baseAddress)) { Console.WriteLine("Server started"); Thread.Sleep(1000000); }它应该正确地绑定到所有接口.
And it should bind correctlly to all interfaces.
更多推荐
Web API自托管
发布评论