VS 调试WebApi ------ localhost 及 ip访问
- 1、localhost访问
-
- [1.1 localhost端口修改](#1.1 localhost端口修改)
- 2、IP访问
-
- [2.1 运行项目](#2.1 运行项目)
- [2.2 打开配置文件](#2.2 打开配置文件)
- [2.3 修改配置文件](#2.3 修改配置文件)
- [2.4 保存后重新运行](#2.4 保存后重新运行)
- 3、最终效果
1、localhost访问
VS运行项目时默认localhost访问。
1.1 localhost端口修改
右键项目选中【属性】 -->> 左上选中【Web】,在此处修改默认端口。如图:

2、IP访问
2.1 运行项目
以项目默认调试模式下运行,选中任务栏右下IIS,显示所有应用程序:

2.2 打开配置文件
选中 待修改IP的项目网站,打开配置文件,找到默认端口节点"<binding protocol="http" bindingInformation="*:xxPort:localhost" />": 此处xxPort为项目默认端口。
2.3 修改配置文件
在默认端口节点信息下,增加"<binding protocol="http" bindingInformation="xxIP:8186:*" />"
此处xxIP为待修改的IP信息,例如 192.168.100.100。

2.4 保存后重新运行
3、最终效果
网站运行应用程序:

浏览器验证结果:
【完结】