visual studio模拟本地IIS
1.运行Web项目,并在对应的文件夹中找到隐藏文件夹 .vs 下的applicationhost.config文件
2.找到文件applicationhost.config中找到类似下面的节点
<site name="项目名称" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\xxx\xxx\项目名称" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:23955:localhost" />
<binding protocol="http" bindingInformation="*:23955:127.0.0.1" />
<binding protocol="http" bindingInformation="*:23955:192.168.110.84" />
<binding protocol="http" bindingInformation="*:23955:192.168.163.1" />
<binding protocol="http" bindingInformation="*:23955:192.168.201.1" />
</bindings>
</site>
3.获取本机局域网IP
,并在site节点中增加一行 <binding protocol="http" bindingInformation="*:23955:局域网IP" />
,如:获取到的局域网IP为192.168.110.84则<binding protocol="http" bindingInformation="*:23955:192.168.110.84" />
4.关闭防火墙/增加防火墙端口入站规则
5.使用管理员身份重启visual studio并运行网站项目,若不使用管理员身份运行时.可能会出现:
HTTP Error 400. The request hostname is invalid.
6.打开其他属于同一局域网电脑,看能否访问得到http://192.168.110.84:23955
VS本地调试 HTTP Error 400. The request hostname is invalid - 狼窝窝 - 博客园 (cnblogs.com)
解决报错HTTP Error 400. The request hostname is invalid._刹那的博客-CSDN博客