解決 VS的IISExpress localhost能夠訪問,127.0.0.1和本機ip訪問不了(錯誤400)

找到IISExpress的配置文件,位於 C:\Users\Administrator\Documents\IISExpress\config文件夾下,打開applicationhost.config,找到以下代碼:app

<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>

添加一行http配置信息爲:url

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

以管理員身份打開CMD命令窗口

輸入以下命令:

netsh http add urlacl url=http://10.1.186.198:60736/ user=everyone


若是報錯請確認是不是以管理員身份運行的CMD。重啓IISExpress,此時應該就可使用IP地址訪問了。

另外,要記得關閉防火牆。

spa

相關文章
相關標籤/搜索