今天嘗試利用Android客戶端Web瀏覽器訪問VS2012 IIS Express調試中的Web應用,發現這個IIS Express僅支持localhost主機名地址訪問。
上網搜索找到解決方案,幾經嘗試最后結果如下:
在\Users\YourName\My Documents\IISExpress\config\applicationhost.config文件中找到正在調試的Web應用的設置行:
<site name="HengShen.Pts.Web" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\Users\VMUser\Documents\Visual Studio 2012\Projects\PtsSolution\HengShen.Pts.Web" /> </application> <bindings> <binding protocol="http" bindingInformation="*:40000:localhost" /> </bindings> </site>
將倒數3行的localhost刪掉,冒號要保留。
然后,關閉這台電腦的防火牆(我是在VMWare Fusion虛擬機中做開發,關閉防火牆對安全沒啥影響。)
或者對防火牆做相應設置,可以參考下面的網址:
http://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer
http://stackoverflow.com/questions/4866547/binding-iis-express-to-an-ip-address