VS2015 默认使用 IIS Express
默认地址 localhost:port/
想修改为 ip:port
启动项目,右击右下角IIS Express图标,选择“显示所有应用程序”
界面内会显示出当前站点信息,点击需要更改的站点
点击下方配置“xxxxxxxx\applicationhost.config”,修改该文件
找到如下区域,在下方新增一条binding,将localhost改为ip
<site name="xxxxxxx" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="xxxxxxxxxx" /> </application> <bindings> <binding protocol="http" bindingInformation="*:54682:localhost" /> <binding protocol="http" bindingInformation="*:54682:192.168.8.138" /> </bindings> </site>重启VS即可
所有操作均在管理员模式下进行
修改防火墙
在“入站规则”中添加一条bypass记录
“新建规则”->“自定义”->“所有程序”->“任何协议”->“指定/任意本地IP地址->指定/任意远程IP地址”->“允许连接”
完成