配置IISExpress允许外部访问

1.找到IISExpress的配置文件,位于 <文档>/IISExpress/config文件夹下,打开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
同样,将IP地址和端口改为你自己的。如果报错请确认是否是以管理员身份运行的CMD。重启IISExpress,此时应该就可以使用IP地址访问了

3..完成上面两部之后,由于防火墙的原因,其他的电脑可能还无法访问你的服务器,如果出现这种情况,采用下面的方法(这里系统是win8.1)
(1)控制面板(查看方式选择类别)->系统和安全->Windows防火墙,在左侧选择高级设置
(2)右击入站规则->新建规则->端口->特定本地端口处输入8080->允许连接->3个选项全选->输入新规则名称->完成
现在外部程序就可以访问你的IISExpress了
 
原文地址:http://blog.csdn.net/zhangjk1993/article/details/36671105
posted @ 2018-02-24 12:41  麻将我会  阅读(275)  评论(1编辑  收藏  举报