IIS Express是Visual Stuido自帶的微型Web服務器,簡單易用。
IIS Express默認只允許本機訪問,通過Visual Studio調試Web程序時,我們有時需要通過外部訪問IIS Express以發現問題。我們可以通過以下簡單配置使IIS Express供外部訪問。
1、修改配置文件
IIS Express的配置文件為 文稿(文檔庫|我的文檔)\IISExpress\config\applicationhost.config,用文本編輯器(記事本即可)打開此文件。搜索要允許外部訪問的程序的名稱,形同如下代碼:
1 <site name="Cis.Csc.Web" id="10"> 2 <application path="/" applicationPool="Clr4IntegratedAppPool"> 3 <virtualDirectory path="/" physicalPath="C:\Users\Frank\Source\Repos\newhealthylife-csc\Cis.Csc.Web" /> 4 </application> 5 <bindings> 6 <binding protocol="http" bindingInformation="*:43944:localhost" /> 7 </bindings> 8 </site>
在第6行之后添加如下配置
1 <binding protocol="http" bindingInformation="*:43944:計算機名或IP地址" />
2、添加保留地址
在cmd命令行中執行以下命令:
httpcfg set urlacl /u http://計算機名或IP地址:43944/ /a D:(A;;GX;;;WD) (Windows XP)
netsh http add urlacl url=http://計算機名或IP地址:43944/ user=everyone (Windows 7或更高,以管理員身份的運行cmd)
3、修改防火牆
關閉系統防火牆即可。如果擔心系統安全,也可以只放開防火牆的以上配置的端口。(具體防火牆端口配置參見 http://jingyan.baidu.com/article/ae97a646acb5a0bbfd461d83.html)
現在我們可以在其他機器上通過IP+端口方式訪問IIS Express啦。