配置IISExpress容許外部訪問

1.找到IISExpress的配置文件,位於 <文檔>/IISExpress/config文件夾下,打開applicationhost.config,找到以下代碼:
[html]  view plain  copy
 
  1. <site name="WebSite1" id="1" serverAutoStart="true">  
  2.       <application path="/">  
  3.            <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />  
  4.       </application>  
  5.       <bindings>  
  6.            <binding protocol="http" bindingInformation=":8080:localhost" />  
  7.       </bindings>  
  8. </site>  
 其中name是你Web項目的名稱,找到對應你項目的配置,而後在 
[html]  view plain  copy
 
  1. <binding protocol="http" bindingInformation="*:8080:localhost" />  
後面加上
[html]  view plain  copy
 
  1. <binding protocol="http" bindingInformation="*:8080:192.168.1.1" />  
其中192.168.1.1改成你本身的Ip地址,8080改成你本身的端口

2.按上面改成後,當你經過IP地址訪問時可能會出現400錯誤,若是出現,就採用下面的方法:
(1)以管理員身份打開CMD命令窗口
(2)輸入以下命令:
[plain]  view plain  copy
 
  1. 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了
相關文章
相關標籤/搜索