配置IISExpress允许外部访问

1.找到IISExpress的配置文件,位于 【项目根文件/.vs/config】文件夹下(.vs 可能是隐藏文件),打开applicationhost.config,找到如下代码:

<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>

其中name是你Web项目的名称,找到对应你项目的配置,然后在

<binding protocol="http" bindingInformation="*:8080:localhost" />

后面加上

<binding protocol="http" bindingInformation="*:8080:192.168.1.1" />   

其中192.168.1.1改为你自己的Ip地址,8080改为你自己的端口

2.按上面改为后,当你通过IP地址访问时可能会出现400错误,如果出现,就采用下面的方法:
(1)以管理员身份打开CMD命令窗口
(2)输入如下命令:

  netsh http add urlacl url=http://192.168.1.1:8080/ user=everyone

之后重启IISExpress,如出现 无法启动  IIS Express Web 服务器,考虑以管理员身份运行vs

posted @ 2016-07-28 14:01  Prorsal  阅读(783)  评论(0编辑  收藏  举报